Configuring additional IP addresses

Configuring additional IP addresses

Upon ordering a Dedicated Server or VPS you will receive one IPv4 address and one /64 IPv6 subnet. As an example, this could be the IPv4 address 192.51.100.10 and the IPv6 subnet 2001:0db8:2a02:c200::/64.

Your server comes pre-configured with this IPv4 (192.51.100.10) and one IPv6 address (2001:0db8:2a02:c200:0000:0000:0000:0001). Additional IPv4 addresses can be ordered by contacting us at info@cairowebdesign.com or through our support tickets at: https://www.cairowebdesign.com/billing/contact.php  These additional IPv4 address will not be added to your system automatically but will have to be configured manually.

The following will give an overview on how to configure additional IP addresses on the most popular operating systems. The server used in these examples has the primary IPv4 address 192.51.100.10 and will receive the additional IPv4 addresses 192.51.100.42 and 192.0.2.23. As a general rule we recommend configuring these addresses with a netmask of 255.255.255.255 (/32) and /64 respectively and without adding a new gateway.

 

CentOS 6.x

CentOS has all its network interface configuration files stored in /etc/sysconfig/network-scripts/. In order to configure additional IPv4 addresses, one virtual interface per additional IPv4 address has to be created. If the main interface is e.g. eth0, the virtual interfaces would be named eth0:0eth0:1eth0:2 and so on. Their configurations reside in individual configuration files named ifcfg-eth0:0ifcfg-eth0:1ifcfg-eth0:2receptively.

#/etc/sysconfig/network-scripts/ifcfg-eth0:0
DEVICE=eth0:0
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.51.100.42
NETMASK=255.255.255.255

#/etc/sysconfig/network-scripts/ifcfg-eth0:1
DEVICE=eth0:1
BOOTPROTO=none
ONBOOT=yes
IPADDR=192.0.2.23
NETMASK=255.255.255.255

Additional IPv6 addresses can be specified using the variable IPV6ADDR_SECONDARIES in the interface's primary configuration file (/etc/sysconfig/network-scripts/ifcfg-eth0 in case of eth0). Multiple addresses are separated by a white space:

#/etc/sysconfig/network-scripts/ifcfg-eth0
...
IPV6ADDR_SECONDARIES=2001:0db8:2a02:c200:0000:0000:0000:0002/64 2001:0db8:2a02:c200:0000:0000:0000:0003/64
...

To apply the changes, restart the network service:

service network restart

CentOS 7.x / Fedora

The network interface configuration files of both CentOS 7.x and Fedora are stored under /etc/sysconfig/network-scripts/. Additional IPv4 addresses can be added to the respective interface's configuration file by using variables of the pattern IPADDR0IPADDR1IPADDR2 and PREFIX0PREFIX1PREFIX2 etc., in case of e.g. eth0 this would be /etc/sysconfig/network-scripts/ifcfg-eth0:

#/etc/sysconfig/network-scripts/ifcfg-eth0
...
IPADDR0=192.51.100.42
PREFIX0=32
IPADDR1=192.0.2.23
PREFIX1=32
...

The old method using virtual interfaces as employed in CentOS 6.x and described above will also still work.

Additional IPv6 addresses can be specified using the variable IPV6ADDR_SECONDARIES in the interface's primary configuration file (/etc/sysconfig/network-scripts/ifcfg-eth0 in case of eth0). Multiple addresses are separated by a white space:

#/etc/sysconfig/network-scripts/ifcfg-eth0
...
IPV6ADDR_SECONDARIES=2001:0db8:2a02:c200:0000:0000:0000:0002/64 2001:0db8:2a02:c200:0000:0000:0000:0003/64
...

To apply the changes, restart the network service:

service network restart

cPanel

With cPanel there is no need to deal with configuration files. Log in to WHM and navigate to "IP Functions" » "Add a New IP Address". Enter the IP address, select subnet mask 255.255.255.255 and click "Submit"

 


Debian / Ubuntu (until 17.04)

Debian's and Ubuntu's network interface configuration is stored in /etc/network/interfaces. Additional IP addresses can be assigned by adding them in separate iface</code sections. The following adds 192.51.100.42 and 192.0.2.23 to eth0 whose primary address is 192.51.100.10:

#/etc/network/interfaces
auto eth0
allow-hotplug eth0
iface eth0 inet static
address 192.51.100.10
netmask 255.255.255.255
gateway 192.51.100.1

iface eth0 inet static
address 192.51.100.42
netmask 255.255.255.255

iface eth0 inet static
address 192.0.2.23
netmask 255.255.255.255
...

Additional IPv6 addresses are configured similarly:

#/etc/network/interfaces
...
iface eth0 inet6 static
address 2001:0db8:2a02:c200:0123:4567:89ab:0001
netmask 112
gateway fe80::1
accept_ra 0
autoconf 0
privext 0


iface eth0 inet6 static
address 2001:0db8:2a02:c200:0000:0000:0000:0002
netmask 64
...

To apply the changes, restart the networking service:

service networking restart

Or:

ifdown eth0; ifup eth0


Ubuntu (17.10 and above)

In Ubuntu beginning with version 17.10, you can find the network configuration in the file /etc/netplan/01-netcfg.yaml. With this method you can assign additional IPv4 and IPv6 addresses to the interface eth0. Additionally to the main IPv4 address 192.51.100.10 and the first IPv6 address of your IPv6 network, you might configure the additional IPv4 addresses 192.51.100.42 and 192.0.2.23 and the additional  IPv6 addresses 2001:0db8:2a02:c200:0000:0000:0000:0002 and 2001:0db8:2a02:c200:0000:0000:0000:0003 in the area  addresses: below of eth0: . It is important to keep the correct indentation!

#/etc/netplan/01-netcfg.yaml
network:
version: 2
renderer: networkd
ethernets:
eth0:
match:
macaddress: 00:50:56:3d:c3:aa
addresses:
- 192.51.100.10/24
- 192.51.100.42/24
- 192.0.2.23/24
- 2001:0db8:2a02:c200:0000:0000:0000:0001/64
- 2001:0db8:2a02:c200:0000:0000:0000:0002/64
- 2001:0db8:2a02:c200:0000:0000:0000:0003/64
gateway4: 192.51.100.1
gateway6: fe80::1
nameservers:
search: [ invalid ]
addresses:
- 79.143.183.251
- 79.143.183.252
- 2a02:c205::1:53
- 2a02:c205::2:53

To apply the changes, please enter this command:

netplan apply

 



Esta resposta lhe foi útil?

 Imprimir este Artigo

Veja também

Data Center Locations

Our server based on more than 60 data centers across the United States, Canada, Europe and Asia.

Servers Uptime Guarantee

Your website and applications are essential when it comes to the success of your business. At...

Obligations

Our Obligations:1. In addition to providing the Services to you as set out in this Agreement, we...

Price Match Policy

General: Subject to the conditions set forth below, Cairo Web Design ® will match the prices...

Privacy Policy

Cairo Web Design ® is committed to protecting your privacy. This Privacy Policy will explain to...