December 15, 2006

Setting Hostname in Redhat Linux

  1. Check which DHCP client are you using dhcpcd , dhclient and 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
  4. NETWORKING=yes
    HOSTNAME=bacan01-l-t1
    DHCP_HOSTNAME=REDHAT

    where REDHAT is the new hostname
  5. In case you are using dhclient, do the setup as follows
  6. Remove dhclient-eth0.leases file, which mostly resides under /var/lib/dhcp where eth0 is the interface name.
  7. In case you are using dhcpcd/pump, Edit /sbin/ifup script
  8. 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
  9. /sbin/dhcpcd -i $DEVICE -h $HOSTNAME
    or
    /sbin/pump –i $DEVICE -h $HOSTNAME
  10. Remove all the files under /etc/dhcpc directory, like *.cache, *.org and *.info
  11. Remove un-neccessary entries from /etc/hosts such that it looks like
  12. 127.0.0.1 localhost localhost.localdomain
  13. Restart the network service
  14. /etc/init.d/network restart
    or
  15. service restart network
  16. Check the IP Address using ifconfig eth0
  17. Do a nslookup to see whether the IP points to the new hostname.
  18. eg. $> nslookup 155.123.33.23 It should be pointing to the new hostname.

No comments: