Site icon UnixArena

How to change the Solaris host name on fly

All the hosts which are in same network should have unique hostname.In this post,we will see that how to change the hostname of the Solaris machine.
To change the hostname on fly . (Applicable for Global & local zone)
(Not recommend while running applications)
bash-3.00# hostname node2
To make this change persistent you have to modify the below mentioned three files. 
Cause:Don’t rename the host in fly , it may affect the running applications on the system. 

Now you can see hostname got changed to node2
bash-3.00# uname -a
SunOS node2 5.10 Generic_142910-17 i86pc i386 i86pc
bash-3.00#


Global zone:
To check the current hostname
bash-3.00# uname -a
SunOS node1 5.10 Generic_142910-17 i86pc i386 i86pc

Configured IP address
bash-3.00# ifconfig -a
lo0: flags=2001000849<UP,LOOPBACK,RUNNING,MULTICAST,IPv4,VIRTUAL> mtu 8232 index 1
        inet 127.0.0.1 netmask ff000000
e1000g0: flags=1000843<UP,BROADCAST,RUNNING,MULTICAST,IPv4> mtu 1500 index 2
        inet 192.168.2.5 netmask ffffff00 broadcast 192.168.2.255
        ether 0:c:29:89:e8:8d

Current hosts file.
bash-3.00# cat /etc/hosts
#
# Internet host table
#
::1 localhost
127.0.0.1 localhost
192.168.2.5 node1 loghost

In order to chnage the hostname ,we have to modify three files
1./etc/hosts
2./etc/hostname.xxxxx
3/etc/nodename

First you need to modifiy /etc/hosts file
“/etc/hosts” [Read only] 6 lines, 88 characters
#
# Internet host table
#
::1 localhost
127.0.0.1 localhost
192.168.2.6 node2 loghost

Second, you need to modifiy  /etc/hostname.XXXX
bash-3.00# vi /etc/hostname.e1000g0
“/etc/hostname.e1000g0” 1 line, 6 characters
node2

Third, you need to modifiy /etc/nodename
bash-3.00# vi /etc/nodename
“/etc/nodename” 1 line, 6 characters
node2


After modifying the above files,you need to reboot the server to take effect.
Non global zone:
How to rename a zone (hostname) and change IP Address
# Login into zone using zlogin command
Edit the files with the new values hostname and IP Address:
  1. /etc/inet/ipnodes
  2. /etc/inet/hosts
# Global ZONE
Change hostname and IP Address by “zonecfg” command.

# global# zonecfg -z arenazone
# zonecfg:arenazone> set zonename=newhost
# zonecfg:newhost> commit
# zonecfg:newhost> set address=xxx.xxx.xxx.xxx
# zonecfg:newhost> end
# zonecfg:newhost> verify
# zonecfg:newhost> commit
# zonecfg:newhost> exit

# Reboot the zone
global# zoneadm -z arenazone reboot

Thank you for reading this article.

Please leave a comment if you have any doubt ,i will get back to you as soon as possible.


Exit mobile version