How can I (from CLI) assign multiple IP addresses to one interface?

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
asked Nov 8, 2014 at 18:45 13.3k 37 37 gold badges 48 48 silver badges 87 87 bronze badges ifconfig is deprecated? I didn't know. Commented Nov 8, 2014 at 18:53

@Mahesh Yeah, ifconfig is an artifact from the SysV era. 'iproute2' is the more modern tool. ifconfig will be around for a while on various distros, but yeah, it's deprecated; "deprecated" is just a colloquialism we used to denote "look for something newer to use".

Commented Jan 4, 2016 at 16:16

3 Answers 3

  1. If you need an additional IP address just for the moment you can add it to any interface on your machine with
 sudo ip address add / dev
for instance
 sudo ip address add 172.16.100.17/24 dev eth0 

would add 172.16.100.17 using a 24 bit network prefix to the list of addresses configured for your eth0 . You can check the result with

ip address show eth0 
and you can delete this address again with
sudo ip address del 172.16.100.17/24 dev eth0 
iface eth0 static address 172.16.100.17/24 
so that it looks like
iface eth0 inet dhcp iface eth0 inet static address 172.16.100.17/24 iface eth0 inet static address 172.16.24.11/24 

You can even keep the dhcp for the primary address. To activate these settings without a reboot use ifdown/ifup like

sudo ifdown eth0 && sudo ifup eth0 
133 3 3 bronze badges answered Nov 8, 2014 at 19:10 13.3k 37 37 gold badges 48 48 silver badges 87 87 bronze badges You can maybe make an vpn whit more then one ip address by installing from from software manager. Commented Nov 8, 2014 at 19:23 No reboot is required on Ubuntu 16.04.3 LTS after adding or deleting an IP Commented Nov 9, 2017 at 17:55 looks like ifdown is deprecated in newer Ubuntu versions. Commented Jun 10, 2018 at 4:29

With the new toolkit, it is as easy as with the old to add new ip addresses:

ip addr add 192.168.1.1/24 dev eth0 

When looking with ip addr show again, you see the second ip address assigned to the interface:

2: eth0: mtu 1500 qdisc pfifo_fast state UP qlen 1000 link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff inet 192.168.0.100/24 brd 192.168.0.255 scope global eth0 inet 192.168.1.1/24 scope global eth0 inet6 fe80::223:54ff:fe45:f307/64 scope link valid_lft forever preferred_lft forever 

Remove that ip address with:

ip addr del 192.168.1.1/24 dev eth0 

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: