Home   Profile   Fun
#132 Linux  03.06.2007

How to create IP aliases on Linux


The command ifconfig can be used to create an IP alias with an extra label
ifconfig eth0:0 192.168.1.35 netmask 255.255.255.0 broadcast 192.168.1.255


Another method uses the the command ip from the iproute2 package
ip addr add 192.168.1.35/24 label eth0:0 dev eth0

Add an IP alias without a new label
ip addr add 192.168.1.35/24 dev eth0

Remove an IP address
ip addr delete 192.168.1.35/24 dev eth0

Show all IP adresses including all IP aliases
ip addr show

Remove all IP addresses and aliases from eth0.
(This also removes any IP alias labeled with eth0:* !)
ip addr flush eth0