IP Aliasing

From Leo's Notes
Revision as of 23:36, 25 February 2015 by 136.159.16.240 (talk)
This page was last edited on 25 February 2015, at 23:36.

IP Aliasing is the process of adding additional IP addresses to a single network interface.

Linux

To add an additional IP address to a network device, such as eth0:

ifconfig eth0:0 10.1.1.2 up

To make it persistent, create a ifcfg script with the IP changes:

cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
vi /etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
NAME=eth0:0
IPADDR=10.1.1.2
NETMASK=255.255.255.0
ONBOOT=yes


Ensure that there is no gateway set in the ifcfg-eth0 file because it should be set in /etc/sysconfig/network.

FreeBSD

Under FreeBSD, to add an additional IP address (10.1.1.2, with a netmask of 255.255.255.0) to re0, run:

ifconfig re0 10.1.1.2 netmask 255.255.255.255 alias

The changes above are not persistent and will not survive a reboot. Add the following to /etc/rc.conf to make it persistent:

ifconfig_re0_alias0="10.1.1.2 netmask 255.255.255.255 alias"