On my server I want to assign several IP addresses to one NIC, but without using the deprecated ifconfig
or the obsolete "alias" notation (like eth0:0
) in /etc/network/interfaces
because in IP Aliasing (on www.kernel.org) you can read
IP-aliases are an obsolete way to manage multiple IP-addresses/masks per interface
If you need an additional IP address just for the moment you can add it to any interface on your machine with
for instance
would add
172.16.100.17
using a 24 bit network prefix to the list of addresses configured for youreth0
.You can check the result with
and you can delete this address again with
Of course these changes are lost when you reboot your machine.
To make the additional addresses permanent you can edit the file
/etc/network/interfaces
by adding as many stanzas of the formso that it looks like
You can even keep the
dhcp
for the primary address.To activate these settings without a reboot use
ifdown/ifup
likeIt is essential to put those two commands into one line if you are remoting into the server because the first one will drop your connection! Given in this way the ssh-session will survive.
With the new toolkit, it is as easy as with the old to add new ip addresses:
When looking with
ip addr show
again, you see the second ip address assigned to the interface:Remove that ip address with:
The iproute2 suite:
The iproute2 suite is the communication suite for interprocess communication beween the kernel and the user space via the netlink protocol. It should replace the whole standard network tools. Here is what they replace:
ifconfig
-->ip addr
andip link
route
-->ip route
arp
-->ip neigh
iptunnel
-->ip tunnel
ipmaddr
-->ip maddr
netstat
-->ss
One way is: