For IONOS VPS purchased after 16 May 2023

This article explains how to add additional, public IPv4 addresses on a VPS that has CentOS 7 installed.

Attention

These instructions are valid only for the VPS.

How to add IPv4 addresses and IPv6 addresses on a cloud server or vServer is described in the following article:

Adding Public IPv4 and IPv6 Addresses on a Linux Server (CentOS 7)

How to add IPv4 addresses and IPv6 addresses on a Dedicated Server is described in the following articles:

Adding Public IPv4 Address on a Dedicated Server (CentOS 7)

Adding a Public IPv6 Address on a Dedicated Server (CentOS 7)

To configure another public IPv4 address in CentOS 7:

Requirements
  • You assigned an additional, public IPv4 address to your server in the Cloud Panel.

  • You logged in to the server.

  • You made a note of the IPv4 addresses of the server.

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

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

  • Create an Ethernet alias and append a sequential number 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, enter the following command:

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

Notes
  • The vi editor has an insert mode and a command mode. You can enter the insert mode by pressing the [i] key. In this mode, the entered characters are immediately inserted into the text. To enter the command mode, press [ESC] afterwards. When you use command mode, your keyboard input is interpreted as a command.

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

  • To add an additional public IPv4 address to the network interface configuration, 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.

  • Perform a reboot of the server. To do this, enter the following command:

    [root@localhost ~]# reboot

    The SSH connection is interrupted after you enter the command.

  • Log in to the server again.

  • To check if the additional public IPv4 address has been added, enter the following command:

    [root@localhost ~]# ip addr

    The additional public IPv4 address is then displayed. Example:

    [root@ip82-165-34-29 ~]# 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 pfifo_fast state UP group default qlen 1000
        link/ether 02:01:e9:29:97:0f brd ff:ff:ff:ff:ff:ff
        inet 82.165.34.29/32 brd 82.165.34.29 scope global dynamic eth0
           valid_lft 526sec preferred_lft 526sec
        inet 195.20.236.17/32 brd 195.20.236.17 scope global eth0:1
           valid_lft forever preferred_lft forever
        inet6 fe80::1:e9ff:fe29:970f/64 scope link
           valid_lft forever preferred_lft forever

Please Note

If the server becomes unreachable due to a configuration error, you can log in to the server using the remote console and correct the configuration.