Adding a Public IPv4 Address on a Linux Server (CentOS 7)
This article explains how to add an additional public IPv4 address on a server where CentOS 7 is installed.
Requirements
You have assigned an additional public IPv4 address to your server.
You have logged on to the server.
To check the existing network connections, enter the following command:
[root@localhost ~]# nmcli connection show
The network interfaces are then displayed.
Example:[root@localhost ~]# nmcli connection show
NAME UUID TYPE DEVICE
Public_ens192 03da7500-2101-c722-2438-d0d006c28c73 ethernet ens192To add the additional public IPv4 address to the network interface configuration, enter the following command:
sudo nmcli con mod Public_NETWORKINTERFACE +ipv4.addresses "ADDITIONAL IPv4 ADDRESS"
Example:
sudo nmcli con mod Public_ens192 +ipv4.addresses "123.456.789.12"
The additional public IPv4 address will now be added to the network interface.
Enter the following command to restart the server:
[root@localhost ~]# sudo reboot
The SSH connection is interrupted after the command is entered.
Log on to the server again.
To check if the additional public IPv4 address has been added, type the following command:
[root@localhost ~]# ip addr
Then, the additional public IPv4 address is displayed.
Example:[root@localhost ~]# ip addr
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: ens192: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
link/ether 00:50:56:11:18:8f brd ff:ff:ff:ff:ff:ff
inet 217.160.67.241/32 brd 217.160.67.241 scope global noprefixroute ens192
valid_lft forever preferred_lft forever
inet 82.165.68.209/32 brd 82.165.68.209 scope global dynamic noprefixroute ens192
valid_lft 43082sec preferred_lft 43082sec
inet6 fe80::250:56ff:fe11:188f/64 scope link noprefixroute
valid_lft forever preferred_lft forever