Problem
How do I add or remove a virtual IP address/domain, also known as IP alias?
Solution
To add or remove a virtual IP address, also known as virtual domain or IP alias, from your system use the following commands:
1. To add a Virtual IP/Domain:For example, if you had a single NIC card with an address of:
123.234.456.100and you also wanted this NIC to accept traffic for address:
123.234.456.101You would use the following command to add the virtual IP to the NIC interface:
# ifconfig net0 alias 123.234.456.101 netmask 255.255.255.0 broadcast 123.234.456.255After running this command, the system will now accept all packets destined for the addresses
123.234.456.100
123.234.456.101This virtual IP/Domain will remain configured until you reboot. You will need to reconfigure the virtual IP address after every reboot, or automate this by adding the command to the TCP/ip startup file in /etc/rc2.d.
2. To remove this Virtual IP/Domain, reboot, or use this command:
# ifconfig net0 -alias 123.234.456.101If you omit the IP address, it will remove the non-aliased IP address, and the alias address would then become the only address for this interface.
NOTE: All the addresses above are non-functional examples, and would need to be substituted with the correct address/netmask/broadcast for your network.
See also
ifconfig(ADMN)