Identify the main interface

If you want to add a secondary IP, this will be added in addition to your main interface. We will need to identify the main interface to setup additional IP addresses.

Locate the interface with your current main IP address. Use command ip a to show all the network interfaces that are currently in use. Assume that 192.168.1.50 is your main IP and you want to add 192.168.1.51.

root@worldtream:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
     inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
    link/ether aa:aa:0a:a1:11:ee brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.50/24 brd 192.168.1.255 scope global eno2
       valid_lft forever preferred_lft forever
3: eth1: <BROADCAST,MULTICAST> mtu 1500 qdisc mq state DOWN glen 1000
    link/ether aa:aa:0a:a1:11:ed brd ff:ff:ff:ff:ff:ff

In the above example we see that eth0 is currently using 192.168.1.50, this is our main interface.

On the next pages you can find examples of a secondary IP address added, sorted by operating system.

CentOS 6.x / 7.x
Ubuntu 14.x / Ubuntu 16.x
Ubuntu 17.x / 18.x / 20.x