How to add additional IP address Linux
How to add additional IP address Linux
At first, you need to back up, if anything will be done wrong. Below you could find command:
cp /etc/network/interfaces /etc/network/interfaces.backup
Also please make sure that you are one of the root account on your server.
For adding IP address to server’s network interface you need to edit files /root/etc/network/interfaces
For adding IP address to server’s network interface you need to edit files /root/etc/network/interfaces
After coping, you could view and edit file using nano:
nano /etc/network/interfaces
And when you will be there, you should see something like below:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
hwaddress ether 00:00:45:1c:5e:d6
address 192.168.0.1
netmask 255.255.252.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
iface lo inet loopback
auto eth0
iface eth0 inet static
hwaddress ether 00:00:45:1c:5e:d6
address 192.168.0.1
netmask 255.255.252.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
Next one, if you want to add IP below the eth0 and name it eth0:1. It should look something like this:
auto lo
iface lo inet loopback
auto eth0
iface eth0 inet static
hwaddress ether 00:00:45:1c:5e:d6
address 192.168.0.1
netmask 255.255.252.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
auto eth0:1
iface eth0:1 inet static
address 192.168.0.26
netmask 255.255.252.0
iface lo inet loopback
auto eth0
iface eth0 inet static
hwaddress ether 00:00:45:1c:5e:d6
address 192.168.0.1
netmask 255.255.252.0
gateway 192.168.0.1
dns-nameservers 8.8.8.8
auto eth0:1
iface eth0:1 inet static
address 192.168.0.26
netmask 255.255.252.0
Because this new IP is going to be set on the same Ethernet port, you will want to set this as eth0:1 and not eth1. All you will need to add is the new address and its netmask. Once you have this set, save and restart your server either within your cloud control panel or with this command:
shutdown –r now
After rebooting the server, you will have an additional IP on your server.
You might also want to read other articles: