I needed to assign a second IP address to a network interface on a Solaris 2.7 system. The system has 2 network cards, designated hme0 and hme1, each with its own IP address, but I needed to assign a second IP address to the hme0 interface. A webserver, which would normally be at the second IP address, was down and I wanted the webserver on this particular system to assume the functions of the offline system temporarily by responding at the IP address of the server that was down. In order to have a Solaris 2.x system listen on a second IP address on an interface, the following steps can be taken.
- Create an entry in /etc/hosts for the second hostname. In
this particular case I added a
myhost2
entry, so that I had the following entries in the file.
Myhost1 and myhost2 will apply to the same network interface, whereas janus is for the second network interface card in the system. The127.0.0.1 localhost 10.0.74.214 myhost1.example.com myhost1 loghost 10.0.74.193 myhost2.example.com myhost2 192.168.1.1 janus
myhost2
entry is the only new entry. - Create /etc/hostname.hme:n files, or /etc/hostname.le0:n files depending on your system configuration, that contain the hostname for the virtual host n. You don't need to create hostname.hme0:0 as it is the same as hostname.hme0.
The above changes will cause the virtual hosts to be configured at boot
time. If you don't want to reboot the system, you can use the
ifconfig
command to have the system start responding on
the second IP address without rebooting.
# ifconfig hme0:1 up
# ifconfig hme0:1 128.183.72.193 netmask 255.255.255.0
References:
-
FAQs document :How to setup multiple ip for Solaris
Date: March 30, 1998
Freelab -
Configuring Networking
By: Keith Parkansky
Date: May 1, 2002
Solaris x86