Adding virtual hosts in Solaris

IP addresses in Solaris are set by creating a hostname file for an interface and then putting the IP address for that hostname in the /etc/hosts file. Multiple interfaces require a hostname file for each interface, but each interface can have multiple hostname files allowing the creation of multiple IP addresses for the same interface.

For example a machine with an interface called le0:

Create a file /etc/hostname.le0 with the hostname in (can be fully qualified or not).

Add an entry in etc/hosts

10.192.201.34 hostname.domain.tld

 

To create virtual IP addresses (that is have the interface arp for more than one IP address) create hostname files /etc/hostname.le0:1 for the first virtual IP address, /etc/hostname.le0:2 for the second and so on.

Hence in /etc there will now be files:

hostname.le0

hostname.le0:1

hostname.le0:2

the hostname entries for the virtual host created in the same way with a corresponding entry in /etc/hosts

Example:

more /etc/hostname.le0

host1.example.com

more /etc/hostname.le0:1

host2.example.com

more /etc/hostname.le0:2

host3.example.com

more /etc/hosts

127.0.0.1 localhost

10.192.201.34 host1.example.com

10.192.201.35 host2.example.com

10.192.201.36 host3.example.com