Linux - DHCP Client Configuration (RedHat)

1. Check which DHCP client are you using is dhcpcd, dhclient or pump

2. Remove /etc/resolv.conf file and touch a new /etc/resolv.conf
Or do a
cp /dev/null /etc/resolv.conf


3. Add an entry into /etc/sysconfig/network such that it looks as follows

NETWORKING=yes
HOSTNAME=k5rec
DHCP_HOSTNAME=k5rec

where k5rec is the new hostname



4. In case you are using dhclient, do the setup as follows
Remove dhclient-eth0.leases file, which mostly resides under /var/lib/dhcp
where eth0 is the interface name.

5. In case you are using dhcpcd/pump

  • Edit /sbin/ifup script

  • See if the call to dhcpcd and pump include a -h $HOSTNAME switch. If they do not, add them, so the calls looks as follows

  • /sbin/dhcpcd -i $DEVICE -h $HOSTNAME
    or
    /sbin/pump –i $DEVICE -h $HOSTNAME

  • Remove all the files under /etc/dhcpc directory, like *.cache, *.org and *.info


6. Remove un-neccessary entries from /etc/hosts such that it looks like
127.0.0.1 localhost localhost.localdomain


7. Restart the network service
/etc/init.d/network restart
or
service restart network


8. Check the IP Address using ifconfig

9. Do a nslookup to see whether the IP points to the new hostname.
eg.
nslookup 155.123.33.23

It should be pointing to the new hostname.