Changing the IP address in Solaris 10

Changing the IP address of a system in Solaris 10 is not quite the same as other unix/linux variants. I'm a Debian linux user and so this method seemed quite odd to me. Anyways, here's how I figured out how to change the system IP address, if someone knows of a better way, please post a comment using the system below.

So changing the IP address itself it done using the usual ifconfig command.

ifconfig xl0 inet 192.168.1.1 netmask 255.255.255.0 broadcast 192.168.1.255

You then need to change the IP in the hosts file.

vi /etc/hosts

So I'm normally used to having some sort of network configuration file with the ip, netmask, broadcast, gateway, etc. But it seems that in Solaris 10, the IP in your hosts file is matched up with your hostname and that IP is set on boot, so as long as it is set in the hosts file, that's the IP you get. The hostname it looks for is stored in /etc/hostname.<interface>. So then I thought, but then how does it figure out the subnet? I found that answer in /etc/netmasks. So, to break it down, here is where everything is set:

UPDATE: It seems that Solaris 10 now checks the /etc/inet/ipnodes file first before the /etc/hosts file to set the IP. So, if the IP is currently set in /etc/inet/ipnodes, you will have to change it there as well.

  • IP -> /etc/hosts
  • Netmask -> /etc/netmasks
  • Gateway -> /etc/defaultrouter
  • IP (again) -> /etc/inet/ipnodes (This is new in Solaris 10)
  • DNS Servers -> /etc/resolv.conf

And that's that! You now have your IP information set. I'm assuming this means if you have multiple interfaces you have to have different hostnames for each interface... does anyone know this for sure?


Author: DPAK
Created: Nov 3 2005 (last modified Jan 24 2006)
Categories: Solaris
TechByte #77

Warning: By visiting this site and/or by using any information contained herein, you agree to the Techbytes.ca terms of use.


Comment posted by 'chockert' on Jul 26 2007 @ 15:10:01
Great entry! This detail is not present in two Solaris 10 books that are supposed to be complete references.
Comment posted by 'Iain Collins' on Nov 19 2007 @ 11:17:32
Solaris 10 (as with previous versions) changes quite a few files when changing the IP/hostname of a system - and pretty much all rough HOWTO guides that suggest anything other than the official method don't quite get it right, which can lead to problems down the road (e.g. when installing additional packages/patches later on).

The only "officially supported" way to change the IP address in Solaris is to use the sys-unconfig command - and this requires console access and a system reboot (running the command powers down the system).

This idea is of course pretty alien to Linux and BSD users (who are not used to scheduling downtime - certainly not a full reboot and console based reconfiguration - for something as "trivial" as an IP address change). As a result, many people are reluctant to follow the correct procedure.

I would however *strongly* recommend that people do use sys-unconfig (*especially* when changing hostnames on a Solaris system). If there is any reluctance to do this because it's "paramount" that downtime be avoided, it's fair to note that the service should not be running in a setup where the outage of a single system could lead to that, and that the problem is the service design itself - and that really ought to be addressed first.

The man page for sys-unconfig contains a list of the ~20 or so files that are changed when the command is run.

Comment posted by 'Alok' on Jul 13 2008 @ 17:41:14
/etc/inet/ipnodes is a link to /etc/hosts. So, you do not need to change at two locations.

Rest all the details are good. Thanks for sharing!
Comment posted by 'Alok' on Jul 13 2008 @ 17:42:33
... and /etc/hosts is a link to /etc/inet/hosts. So, the key file is /etc/inet/hosts

Add a comment about this TechByte

If you wish to add a comment regarding this TechByte, please use the form below. Please note that by submitting comments using this form you are allowing all of the information submitted to be visible on this website. Any comments submitted using this form will only be shown on the website if they are approved by the administrators of this site. IF APPROVED, COMMENTS MAY TAKE SEVERAL DAYS TO BE POSTED.

Posted By: (Optional)

Comments:


Other TechBytes: