For Dedicated Servers

This article explains how to add an additional public IPv4 address on a Dedicated Server where CentOS 7 is installed.

To configure an additional public IPv4 address in CentOS 7, please proceed as follows:

Requirements
  • In the Cloud Panel, you have assigned an additional public IPv4 address to your server.

  • You have logged on to the server as an administrator.

  • Check the entries in the ifcfg-eth0 file. To do this, enter the following command:

    [root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0

  • To add an additional IP address, you need an Ethernet alias. To do this, a consecutive number is simply appended to the interface name, starting with 1 for the first alias. Thus, the first alias of eth0 is eth0:1. To create the /etc/sysconfig/network-scripts/ifcfg-eth0:1 file with the vi Editor, please enter the following command:

    [root@localhost ~]# vi /etc/sysconfig/network-scripts/ifcfg-eth0:1

Notes
  • The vi Editor has a command mode and an insert mode. To switch to input mode, press [i] on your keyboard. You can now insert the required content or make the required changes. Press the [ESC] key on your keyboard to exit the input mode.

  • To exit vi and save the file, type the command :wq, then press Enter.

  • To customize the network configuration of your server and use an additional public IPv4 address, enter the following information:

    DEVICE=eth0:1
    Type=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=none
    IPADDR=Additional IPv4 address
    PREFIX=32

    Example:

    DEVICE=eth0:1
    Type=Ethernet
    ONBOOT=yes
    NM_CONTROLLED=no
    BOOTPROTO=none
    IPADDR=123.456.789.12
    PREFIX=32

  • Save the file.

  • Restart your server. To do this, enter the following command:

    [root@localhost ~]# reboot

    The SSH connection will be 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

    The additional public IPv4 address will now be displayed. Example:

    [root@4eb7808 ~]# 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: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000
        link/ether 3c:ec:ef:22:65:fa brd ff:ff:ff:ff:ff:ff
        inet 87.106.126.210/32 brd 87.106.126.210 scope global dynamic eth0
           valid_lft 43036sec preferred_lft 43036sec
        inet 82.165.248.110/24 brd 82.165.248.255 scope global eth0:1
           valid_lft forever preferred_lft forever
        inet6 2001:8d8:1801:8298::1/128 scope global dynamic
           valid_lft 3439sec preferred_lft 3439sec
        inet6 fe80::3eec:efff:fe22:65fa/64 scope link
           valid_lft forever preferred_lft forever
    3: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc mq state DOWN group default qlen 1000
        link/ether 3c:ec:ef:22:65:fb brd ff:ff:ff:ff:ff:ff