If you have been given your own private subnet (we still say /29) from your hosting provider and have 5 websites that need their own dedicated IP address. You will be able to add sub-interfaces onto a single NIC (network interface card), and assign each sub-interface with its own dedicated IP address from the subnet.
You will need to be either root or have an user with sudo privileges
1. Edit the interfaces file within the network folder
sudo nano /etc/network/interfaces
2. Add the additional IP addresses under eth0
# The primary network interface 10.10.10.10 - 14 are usable IP addresses auto eth0 iface eth0 inet static address 10.10.10.10 netmask 255.255.255.248 gateway 10.10.10.9 # The Rest of the IP addresses in the /29 auto eth0:1 iface eth0:1 inet static address 10.10.10.11 netmask 255.255.255.248 gateway 10.10.10.9 auto eth0:2 iface eth0:2 inet static address 10.10.10.12 netmask 255.255.255.248 gateway 10.10.10.9
3. Restart the network daemon
sudo /etc/init.d/networking restart
4. Enable the new sub-interface
sudo ifup eth0:1
This will create a NIC alias and therefore allow you add additional IP addresses. This can be done for up to 254 IP addresses
Keeran Marquis
Latest posts by Keeran Marquis (see all)
- Life and Times of an Unemployed Professional Speed Dater #3 - August 5, 2018
- Life and Times of an Unemployed Professional Speed Dater #2 - August 5, 2018
- Life and Times of an Unemployed Professional Speed Dater #1 - August 5, 2018
Hey Kareen,
If we do the same with IPv6, ifconfig show them under ens3 and not under ens3:1 or ens3:2. How to make IPv6 show under subinterfaces? (ubuntu-xenial)
Hi
Ive never tried with v6, i would assume it should be the same but given youre using 16.04 i dont know unfortunately
Cheers
Keeran