Thursday, August 16, 2012

Ubuntu Change host name

SkyHi @ Thursday, August 16, 2012

[user1@ws1 ~]$ sudo vi /etc/hosts       localhost       client1.linux.local client1

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters

[user1@ws1 ~]$ sudo vi /etc/hostname

[user1@ws1  ~]$ sudo hostname client1.linuxcbt.local

Pretty much all software is sensitive to correctly setting the hostname. While I was working at Digg I once brought the entire site down for 2 hours due to making a seemingly innocent change in /etc/hoststhat affected the system's notion of hostname. Tread lightly. That said, you may be slightly confused here. I don't think the HOSTNAME= setting is directly equivalent to how Debian-based distributions use/etc/hostname.
What works for me in a heterogeneous environment is:
1. Set the hostname in the vendor-recommended manner, using a conditional in your config management software.
2. Use the "hostname" command to set the hostname used by the kernel, etc.
3. In /etc/hosts:    localhost     hostname


A typical RHEL/CentOS server setup for a server named "Rizzo" with internal domain "", would look like:
/etc/hosts:   localhost localhost.localdomain localhost4 localhost4.localdomain4
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6 rizzo
[root@Rizzo ~]# hostname 
/var/log/messages snippet:
Dec 15 10:10:13 Rizzo proftpd[19675]: (::ffff:[::ffff:]) - Preparing to               
 chroot to directory '/app/upload/GREEK'
Dec 15 10:10:51 Rizzo proftpd[20660]: (::ffff:[::ffff:]) - FTP session opened.
Dec 15 10:10:51 Rizzo proftpd[20660]: (::ffff:[::ffff:]) - Preparing to chroot                
to directory '/app/upload/ftp/SRRID'