For Server Power Deals and Value Dedicated Server

This article explains how to change the IP address of a server or how to add an additional IP address.

By default, the Dedicated Server are configured for automatic network configuration through DHCP. The server is always assigned the IP address first created in the contract. If you want to change the server address or assign one of the additional addresses, a static IP configuration is necessary.

Note

For network security reasons, all server are configured with a /32 network (netmask 255.255.255.255) and can therefore only reach your gateway and locally configured IP addresses directly. In order to still be able to "talk" to other server in the network segment, all other packets must be routed through the default gateway. This requires a host route to the gateway.

Debian/Ubuntu

Changing the IP Address of the Server
  • Open the file /etc/network/interfaces with the VI Editor.

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

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

  • In the /etc/network/interfaces file, add the following entries and replace the wildcard with the main IPv4 address of the server.

    auto eth0
    iface eth0 inet static
    address <MAIN_IPv4_ADDRESS>
    netmask 255.255.255.255
    gateway 10.255.255.1
    pointopoint 10.255.255.1 

    Network mask, gateway and point-to-point connection must be specified exactly as above. Pay particular attention to the correct spelling of the pointopoint parameter.
    The edited configuration file will look like this:

    # This file describes the network interfaces available on your system
    # and how to activate them. For more information, see interfaces(5).

    # The loopback network interface
    auto lo
    iface lo inet loopback

    # The primary network interface
    auto eth0
    iface eth0 inet static
    address 123.123.123.123
    netmask 255.255.255.255
    gateway 10.255.255.1
    pointopoint 10.255.255.1

    Example:

    # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
    # Generated by debian-installer.

    # The loopback interface
    auto eth0
    iface eth0 inet static
    address 123.123.123.123
    netmask 255.255.255.255
    gateway 10.255.255.1
    pointopoint 10.255.255.1 

    allow-hotplug eth0
    iface eth0 inet6 static
    address 1234:01D1:1234:B000:0000:0000:0001:E123
    netmask 64
    post-up ip -6 route add fe80::1 dev eth0
    post-up ip -6 route add default via fe80::1 dev eth0
    post-down ip -6 route del default via fe80::1 dev eth0
    post-down ip -6 route del fe80::1 dev eth0

  • To restart the network, enter the following command:

    /etc/init.d/networking restart

Add Another IP Address
  • Make sure that the server's main IP address is configured as a static IP address as described above.

  • To add another IP address, enter the following information in the /etc/sysconfig/network/ifcfg-eth0 file:

    auto eth0:1
    allow-hotplug eth0:1
    iface eth0:1 inet static
    address ADDITIONAL-IPv4-ADDRESS/32

    Example:

    # /etc/network/interfaces -- configuration file for ifup(8), ifdown(8)
    # Generated by debian-installer.

    # The loopback interface
    auto eth0
    iface eth0 inet static
    address 123.123.123.123
    netmask 255.255.255.255
    gateway 10.255.255.1
    pointopoint 10.255.255.1

    auto eth0:1
    allow-hotplug eth0:1
    iface eth0:1 inet static
    address 456.456.456.45/32

    allow-hotplug eth0
    iface eth0 inet6 static
    address 1234:01D1:1234:B000:0000:0000:0001:E123
    netmask 64
    post-up ip -6 route add fe80::1 dev eth0
    post-up ip -6 route add default via fe80::1 dev eth0
    post-down ip -6 route del default via fe80::1 dev eth0
    post-down ip -6 route del fe80::1 dev eth0

    Specify an alias to eth0 in the form eth0:x for each additional IP. For the third IP, for example, IP address eth0:2, etc.

CentOS

Change the IP Address of the Server
  • Open the file /etc/sysconfig/network-scripts/ifcfg-eth0 with the VI Editor.

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]. When you use command mode, your keyboard input is interpreted as a command.

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

  • Change this for the static IP configuration as follows and replace the placeholderwith your IP address.

    DEVICE=eth0
    BOOTPROTO=static
    NM_CONTROLLED="yes"
    ONBOOT=yes
    IPADDR0=<MAIN_IPV4_ADDRESS>
    NETMASK=255.255.255.255

  • Now you have to configure the necessary route: To do this, create a configuration file /etc/sysconfig/network-scripts/route-eth0 with the following content:

    ADDRESS0=10.255.255.1
    NETMASK0=255.255.255.255
    ADDRESS1=0.0.0.0
    NETMASK1=0.0.0.0
    GATEWAY1=10.255.255.1

  • To restart the network, enter the following command:

    /sbin/service network restart

Add Another IP Address
  • Ensure that the MAIN IPv4 address of the server is configured as a static IP address as described above.

  • Open the file /etc/sysconfig/network-scripts/ifcfg-eth0 with the VI Editor.

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]. When you use command mode, your keyboard input is interpreted as a command.

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

  • Make sure that the main IP address is entered in the following format:

    IPADDR0=<MAIN_IP_ADDRESS>

  • To configure the additional IPv4 address(es), add the following entry(s) and replace the wildcards:

    IPADDR1=<Additional_IPv4_ADDRESS>
    PREFIX1=32
    IPADDR2=<Additional_IPv4_ADDRESS>
    PREFIX2=32
    IPADDRN=<Additional_IPv4_ADDRESS>
    PREFIXN=32

  • To reboot the server, enter the following command:

    [root@localhost ~]# systemctl reboot

SUSE 13.x

Changing the IP Address of the Server
  • Open the file /etc/sysconfig/network/ifcfg-eth0 with the VI Editor.

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]. When you use command mode, your keyboard input is interpreted as a command.

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

  • To change the MAIN IPv4 address of the server, you must configure it as a static IP address. To do this, change the default values for BOOTPROTO, IPADDR and NETMASK as follows:

    BOOTPROTO='static'
    IPADDR=<MAIN_IPv4_ADDRESS>
    NETMASK=255.255.255.255

  • Create the /etc/sysconfig/network/routes file necessary for manual routing and add the following code there:

    10.255.255.1 0.0.0 255.255.255.255 eth0
    default 10.255.255.1

  • To restart the network, enter the following command:

    /sbin/service network restart

Add Another IP Address
  • Make sure that the server's main IP address is configured as a static IP address as described above.

  • To add another IP address, enter the following information in the /etc/sysconfig/network/ifcfg-eth0 file:

    IPADDR1='ADDITIONAL_IPv4_ADDRESS'
    NETMASK1='255.255.255.0'

    Example:

    IPADDR1='82.165.197.41'
    NETMASK1='255.255.255.0'

  • To restart the network, enter the following command:

    /sbin/service network restart