In my network i have setup a Linux DHCP Server and multiple Solaris machines who obtain all their network information though dhcp. First in the Solaris machine i enable the dhcp client:
ifconfig pcn0 dhcp start
To release the IP and obtain a new one:
ifconfig pcn0 dhcp release
ifconfig pcn0 dhcp start
This is going to obtain the IP, router, netmask.. but something is missing, the DNS servers. The DNS Servers are setup in /etc/resolv.conf, so this file should be updated when the information is got from the DHCP Server. To get this done, create a script called /etc/dhcp/eventhook. This script should have this:
#!/bin/ksh -p
PATH=/bin:/sbin export PATH
umask 0222
# Refresh the domain and name servers on /etc/resolv.conf
insert ()
{
dnsservers=`/sbin/dhcpinfo -i $1 DNSserv`
if [ -n "$dnsservers" ]; then
# remove the old domain and name servers
if [ -f /etc/resolv.conf ]; then
rm -f /tmp/resolv.conf.$$
sed -e ‘/^domain/d’ -e ‘/^nameserver/d’ \
/etc/resolv.conf > /tmp/resolv.conf.$$
fi
# add the new domain
dnsdomain=`/sbin/dhcpinfo -i $1 DNSdmain`
if [ -n "$dnsdomain" ]; then
echo “domain $dnsdomain” >> /tmp/resolv.conf.$$
fi
# add new name servers
for name in $dnsservers; do
echo nameserver $name >> /tmp/resolv.conf.$$
done
mv -f /tmp/resolv.conf.$$ /etc/resolv.conf
fi
}
# Remove the domain and name servers from /etc/resolv.conf
remove ()
{
if [ -f /etc/resolv.conf ]; then
rm -f /tmp/resolv.conf.$$
sed -e ‘/^domain/d’ -e ‘/^nameserver/d’ \
/etc/resolv.conf > /tmp/resolv.conf.$$
mv -f /tmp/resolv.conf.$$ /etc/resolv.conf
fi
}
case $2 in
BOUND | EXTEND)
insert $1
exit 0
;;
EXPIRE | DROP | RELEASE)
remove
exit 0
;;
*)
exit 0
;;
esac














No user commented in " Setup DHCP a Solaris DHCP client "
Follow-up comment rss or Leave a TrackbackLeave A Reply