Since the most important parts of the network configuration are provided via DHCP along with your primary IPv4 address, managing your network stack is quite easy. The instructions here detail how to setup IPv6 and additional IP addresses on CentOS, Ubuntu, and Debian.
To purchase additional IPs, including DDoS-protected IPs, please contact our sales department at support.knownhost.com or sales@knownhost.com.
CentOS 7 has two ways to manage networks. Init scripts which is what we'll cover in this guide, and NetworkManager.
Open a new file using your preferred editor in /etc/sysconfig/network-scripts/ifcfg-eth0:1
. For the sake of this guide we'll use vi
.
vi /etc/sysconfig/network-scripts/ifcfg-eth0:1
If you're using vi
, press i
to enter input mode and paste the following:
BOOTPROTO=static DEVICE=eth0:1 ONBOOT=yes TYPE=Ethernet IPADDR=127.0.0.1 PREFIX=32
You'll want to alter the IPADDR
value to the IP address you're adding. For each additional IP you'll create additional ifcfg-eth0:X
files with X being arbitrary numbers. When doing this make sure the DEVICE
line inside the config matches the interface name from the file name.
After you've finished editing the configuration file save it (^C
, :wq
, return
in vi
) and run the following command to apply the changes:
systemctl restart network
If you did everything properly you can verify the new address was added to the system by running ip a
where you should see your newly added IP listed.
If you want to manage your networks using NetworkManager you can read more into that 1)here.
Adding IPv6 addresses is identical to v4 with the exception of IPADDR
and PREFIX
. Remove them both and add IPV6ADDR
as the following example shows making sure to include the subnet on the end of the IPv6 which should generally be /64
:
BOOTPROTO=static DEVICE=eth0:1 ONBOOT=yes TYPE=Ethernet IPV6ADDR=fd00::/64
Save the file and run systemctl restart network
to apply your changes.
Ubuntu 18.04 uses netplan
for managing IP addresses. netplan
is a bit different from many other distributions network configuration systems in that it uses YAML files to build the network.
Open a new file using your preferred editor in /etc/netplan/99-static.yaml
. For the sake of this guide we'll use vi
.
vi /etc/netplan/99-static.yaml
If you're using vi
, press i
to enter input mode and paste the following:
network: version: 2 renderer: networkd ethernets: ens3: dhcp4: yes dhcp6: no addresses: - 127.0.0.1/24 - 127.0.0.2/24 - fd00::1/64
In the above example, ens3
is the name of the primary network device to which we'll bind the addresses. The list of 'addresses' are the addresses you wish to bind with 127.0.0.x
representing IPv4 addresses and fd00::1/64
representing IPv6 addresses. Using this format you can add as many addresses as needed (if they've been purchased).
Keep in mind that the spacing/indention in YAML is very important.
If you are only binding an IPv6 address then only enter it in the list of addresses and do not create any IPv4 entries.
After you've finished editing the configuration file save it (^C
, :wq
, return
in vi
) and run the following command to apply the changes.
netplan apply
Your new IPs should now be bound to your server. You can confirm this by running ip a
.
root@host:~# ip a <snip> 2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether ff:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff inet 127.0.0.1/24 brd 158.106.142.255 scope global ens3 valid_lft forever preferred_lft forever inet 127.0.0.2/24 brd 170.249.233.255 scope global ens3 valid_lft forever preferred_lft forever inet 127.0.0.0/23 brd 158.106.141.255 scope global dynamic ens3 valid_lft 82390sec preferred_lft 82390sec inet6 fd00::1/64 scope global valid_lft forever preferred_lft forever <snip>
See above.
Ubuntu 16.04 and Debian 9 build and manage networks the same way.
Open a new file using your preferred editor in /etc/network/interfaces.d/99-static.yaml
. For the sake of this guide we'll use vi
.
vi /etc/network/interfaces.d/99-static.yaml
If you're using vi
, press i
to enter input mode and paste the following:
auto ens3:1 ens3:2 ens3:3 iface ens3:1 inet static address 127.0.0.1 iface ens3:2 inet static address 127.0.0.2 iface ens3:3 inet6 static address fd00::/64
In the above example, ens3
is the name of the primary network device to which we'll bind the addresses. As you can see we bound 2 additional IPv4 and one IPv6 address. Make sure when creating new aliased interfaces (ex ens3:1
) that you add them to the top line after auto
so they're started with networking.
After you've finished editing the configuration file save it (^C
, :wq
, return
in vi
) and run the following command to apply the changes.
/etc/init.d/networking restart
Your new IPs should now be bound to your server. You can confirm this by running ip a
.
root@host:~# ip a <snip> 2: ens3: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000 link/ether ff:ff:ff:ff:ff:ff brd ff:ff:ff:ff:ff:ff inet 127.0.0.1/24 brd 158.106.142.255 scope global ens3 valid_lft forever preferred_lft forever inet 127.0.0.2/24 brd 170.249.233.255 scope global ens3 valid_lft forever preferred_lft forever inet 127.0.0.0/23 brd 158.106.141.255 scope global dynamic ens3 valid_lft 82390sec preferred_lft 82390sec inet6 fd00::1/64 scope global valid_lft forever preferred_lft forever <snip>
See above.