Cart

    Sorry, we could not find any results for your search querry.

    Adding an IPv4 or IPv6 address in CentOS 7

    When you order an extra IPv4 address or add an extra IPv6 address to your IP addresses via the TransIP control panel, these cannot be automatically added to your VPS via DHCP. Additional IP addresses are added manually to the network interfaces.

    In this article, we explain how you can statically add an extra IPv4 or IPv6 address to your CentOS 7 VPS. For this, an extra IPv4 and/or IPv6 address is required (depending on which you'd like to add / configure). Don't have an extra address yet? The following articles explain how you can get one:

     

    Click here for a complete overview of all our tutorials for adding an extra or static IPv4 or IPv6 address to various Linux distros. For adding an IPv4 or IPv6 address to a Windows VPS, see this article.

    • This manual is about public IP addresses. In this manual, you will find more information about setting up internal addresses (for your private network).

    A VPS includes 1 IPv4 address by default, but you can expand this to a maximum of 10 IPv4 addresses via the control panel. A maximum limit of 20 IPv4 addresses applies to the VPSs of the PRO series.

    Each VPS has a /64 IPv6 range at its disposal by default, where IP addresses can be added as desired. A /64 IPv6 range contains a total of 18,446,744,073,709,551,616 IP addresses, so the likeliness that you will not have enough is quite small! The default gateway falls outside of the /64 range so as netmask you always use a /48 range.


    Adding an IPv4 address in CentOS 7

     

    Step 1 

    Connect to the VPS via the VPS console or via SSH.


     

    Step 2 

    Once logged in you see the current network interfaces and the set IPs by means of the command:

    ifconfig -a
    

    For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.    

    centos 7 ifconfig


     

    Step 3 

    Please note: Did you use our fast installs feature for VPS and chose for installation via SSH-keys, one time password, or cloud-config user data? Then, additional steps are required. Click 'Fast installs proces' below to view these steps.

    Fast installs proces

    For Fast Installs we make use of Cloud Init. Cloud Init automatically overwrites your netwerk configuration. For this reason Cloud Init or its control over the network (either choice is fine) must be disabled as follows:

     

    Disabling Cloud Init network management

    Open/create the following file:

    nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

    Give the file the following contents. Afterwards, save and close your file  (ctrl + x > y > enter).

    network:
       config: disabled

    You may now proceed with the rest of step 3 from this point.

     

    Disabling Cloud Init

    Cloud Init is only used for the initial installation of your VPS. It can't hurt as such to disable it altogether. All that's required to disable Cloud Init is the creation of the following file:

    touch /etc/cloud/cloud-init.disabled

    You may now proceed with the rest of step 3 from this point.

    Should the changes not take affect after completing this tutorial, the following command may be required:

    dpkg-reconfigure cloud-init

    Now add the extra IPv4 address in the network interfaces. First, open the network configuration file:

    nano /etc/sysconfig/network-scripts/ifcfg-eth0

    Please note: In CentOS 6 an extra interface had to be created for each individual IP address, such as eth0:1, eth0:2, etc. In CentOS 7 this is no longer necessary. 

    centos 7 default ifcfg

    The existing configuration file opens and you add the following: 

    IPADDR0=149.210.175.3
    IPADDR1=149.210.193.224
    IPADDR2=149.210.193.225
    NETMASK0=255.255.255.0
    NETMASK1=255.255.255.0
    NETMASK2=255.255.255.0
    GATEWAY0=149.210.175.1
    GATEWAY1=149.210.193.1
    GATEWAY2=149.210.193.1
    

    IPADDR(x) is the IP address that you want to set and GATEWAY(x) the gateway, which for your IP address can be found in the control panel

    For every IP address that you add, you use an ascending number, i.e. IPADDR0, IPADDR1, IPADDR2, IPADDR3, etc. The same applies to gateways if applicable. You need to leave the (sub)NETMASK at 255.255.255.0. 

    Save the changes and exit nano (ctrl + x > y > enter).  


     

    Step 4 

    Reset your network interfaces with the following command to use the new IP address: 

    systemctl restart network

     

    Step 5 

    If you run ifconfig -a or ip addr again you will see the newly added IPv4 address. You can test this IP address by performing a ping test from another computer / IP. 

    centos 7 added ipv4 address

    Repeat the above steps if you want to add more IP addresses. In addition, it is not mandatory to add the gateway if the extra IP address is in the same /24 range. If this is not the case then you will have to add this, because otherwise, you will have trouble reaching other IPs within the TransIP network. 


    Adding an IPv6 address in CentOS 7

     

    Step 1 

    Connect to the VPS via the VPS console or via SSH.


     

    Step 2 

    Once logged in you see the current network interfaces and the set IPs by means of the command:

    ifconfig -a

    For the next steps, it is especially important that you are aware of the correct adapter name. Which is eth0 in this example.  

    centos ifconfig


     

    Step 3 

    Please note: Did you use our fast installs feature for VPS and chose for installation via SSH-keys, one time password, or cloud-config user data? Then, additional steps are required. Click 'Fast installs proces' below to view these steps.

    Fast installs proces

    For Fast Installs we make use of Cloud Init. Cloud Init automatically overwrites your netwerk configuration. For this reason Cloud Init or its control over the network (either choice is fine) must be disabled as follows:

     

    Disabling Cloud Init network management

    Open/create the following file:

    nano /etc/cloud/cloud.cfg.d/99-disable-network-config.cfg

    Give the file the following contents. Afterwards, save and close your file  (ctrl + x > y > enter).

    network:
       config: disabled

    You may now proceed with the rest of step 3 from this point.

     

    Disabling Cloud Init

    Cloud Init is only used for the initial installation of your VPS. It can't hurt as such to disable it altogether. All that's required to disable Cloud Init is the creation of the following file:

    touch /etc/cloud/cloud-init.disabled

    You may now proceed with the rest of step 3 from this point.

    Should the changes not take affect after completing this tutorial, the following command may be required:

    dpkg-reconfigure cloud-init

    Now add the extra IPv6 address in the network interfaces. First, open the network configuration file:

    nano /etc/sysconfig/network-scripts/ifcfg-eth0

    You will see an output that looks like the screenshot below. 

    centos eth0 ipv6

    In the opened configuration file, add the following lines if they are missing: 

    IPV6INIT=yes
    IPV6ADDR=2a01:7c8:aab8:77::1337
    IPV6_DEFAULTGW=2a01:7c8:aab8::1
    

    Save the changes and exit nano (ctrl + x > y > enter). 

    If you want to add more IPv6 addresses, add the following line:

    IPV6ADDR_SECONDARIES="2a01:7c8:aab8:77::1338 2a01:7c8:aab8:77::1339" (etc.)

     

    Step 4 

    Reset your network interfaces with the following command to use the new IP address: 

    systemctl restart network

    If you run ifconfig -a or ip addr again you will see the newly added IPv6 address. You can test this IP address by performing a ping test from another computer / IP. 

    Repeat the above steps if you want to add more IP addresses. 


     

    Should you have any questions left regarding this article, do not hesitate to contact our support department. You can reach them via the ‘Contact Us’ button at the bottom of this page.

    Need help?

    Receive personal support from our supporters

    Contact us