!!! Do you know that Sun decided to defer Solaris on Intel ? For more information : go Save Solaris x86

/etc/init.d/network behavior on Solaris 8

I read the network script /etc/init.d/network when there were a post on Solaris On Intel list about the virtual interface was not up, althought it was set correctly. I tried to do it, and out of the world, I got the same error, although I used to do this many times before. Therefore I decided to read that script on Solaris 8.

On Solaris, in order to configure the ip for a network interface, we use /etc/hostname.xyzN with xyz is the name of the driver for the nic, and N is the order number of instance of that nic. For example, my Solaris box uses one 3c595, the corresponding dirver is elx, and the file to configure the ip for that nic is /etc/hostname.elx0.

For virtual interface, that file will be /etc/hostname.elx0:1, /etc/hostname.elx0:2, etc.

Normally, the file /etc/hostname.xyzN will have one line containg the hostname for that interface. In my system, it contains ironwill-vpn.

How does the system know which ip address will bind with this nic ? It reads the coressponding file hostname.xyzN , gets the name and searches for the name in /etc/hosts. In my /etc/hosts, I have an entry 192.168.253.4 for ironwill-vpn.

How does the system know which netmask will bind with this ip address ? It checks the /etc/netmasks.

The automatic search and bind the ip address to the nic is carried out by the command

/sbin/ifconfig xyz inet netmask + broadcast + up

Pay attention the char + after netmask and broadcast. This + tells ifconfig to search for ip and netmask. After this command is run, the interface will be up. So where is the problem as stated at the beginning ?

Looking into the script at the part of Ipv4, the logic is as follows:

. If the file /etc/hostname.zyzN has more than one lines, each line will be configured for that interface with
/sbin/ifconfig xyzN inet param-string

with param-string is the content of the corresponding line. This leads to the interface is not up, except param-string has the correct format & contains the keyword "up" ( for example, the line contains "some-valid-host-name up" )

. If /etc/hostname.xyzN has only one line, the interface will be init as

/sbin/ifconfig xyzN inet param-string netmask + broadcast + up.
In this case, the param-string is often the hostname.

For example my /etc/hostname.elx0 has 2 lines, the first line has ironwill-vpn, and the second one is a blank line, ( this is often the case when I type in the hostname the press enter ), the interface will be configure by
/sbin/ifconfig elx0 inet ironwill-vpn

This leads to the interface will be bind with the ip that is corresponding to ironwill-vpn, default netmask but not up. Remember that the default netmask is often matched with your real netmask, that is specified in /etc/netmasks.

After deleting the blank line ( so that it contains only one line of ironwill-vpn ) , and rebooting the server ( or unplumb the interface and run the network script again ), the interface is up and binded with correct ip and netmask.

 

The problem is fixed, but the question is why Solaris 8 needs to have such complicated network script ? Why don’t it prcess only one line ? I don ´ t know.