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 is your main IP and you want to add

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 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 brd 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, 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