How to add Extra IP(s) on Linux

IMPORTANT: There seems to be issues with more than 1 IP on Ubuntu, we've so far only figured out how to get all IPs to work on Centos 7

So for Centos 7, ssh and login as root to one of the IP that pings, once inside, type

nmtui

and go to "Edit a connection" and delete ALL except ens18. Select ens18, go to Edit then under "IPv4 Addresses", click Add for every one of your IPs with /32 at the end so you will add

xxx.xxx.xxx.xxx/32
yyy.yyy.yyy.yyy/32

And however many IPs you have. Then click OK then Quit and type reboot to reboot VPS

On Centos: create /etc/sysconfig/network-scripts/ifcfg-eth2 (using vi command) that contains:

DEVICE=eth2
BOOTPROTO=dhcp
ONBOOT=yes

Then reboot vps. If still not working, if working IP is on eth0, then try set extra IP as eth0:0 with DHCP. More info

NOTE: On Centos 7 Min, there's no ifconfig so you need to install it first via command

yum -y install net-tools

On Ubuntu, you modify sudo vi /etc/network/interfaces. Then sudo /etc/init.d/networking restart or reboot VPS or Stop VPS then Start VPS via web panel.

auto eth0:0
iface eth0:0 inet dhcp

NOTE: Again, assuming working IP is on eth0. Some ubuntu/debian may show ens18 instead of eth0 so you will use ens18:0, ens18:1, etc... auto ens18:0 iface ens18:0 inet dhcp Hint: You can find out where working IP is on by typing ifconfig

Below is a sample of our Ubuntu 16.10 template on New KVM SSD Cached Custom plan:

First fine one from all the IPs assigned to you that pings, say in this matter, it is 23.226.214.199, then you ssh to that IP


rentvps@ubuntu:~$ ifconfig
ens18: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 63.223.115.198 netmask 255.255.255.224 broadcast 63.223.115.223
inet6 fe80::8f8:9ff:fe5f:db7f prefixlen 64 scopeid 0x20<link>
ether 0a:f8:09:5f:db:7f txqueuelen 1000 (Ethernet)
RX packets 7014 bytes 563071 (563.0 KB)
RX errors 166 dropped 0 overruns 0 frame 166
TX packets 76 bytes 7100 (7.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0

ens19: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 23.226.214.199 netmask 255.255.255.224 broadcast 23.226.214.223
inet6 fe80::101a:99ff:fe4f:5081 prefixlen 64 scopeid 0x20<link>
ether 12:1a:99:4f:50:81 txqueuelen 1000 (Ethernet)
RX packets 7757 bytes 1413464 (1.4 MB)
RX errors 164 dropped 0 overruns 0 frame 164
TX packets 271 bytes 32188 (32.1 KB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0


You will find the IP on ens18 is not pinging so you now need to modify /etc/network/interfaces by typing

sudo vi /etc/network/interfaces

and add ens19:0 below ens19 and delete the ens18 entries so you will have (you get the IP and netmask from above)

auto ens19
iface ens19 inet dhcp

auto ens19:0
iface ens19:0 inet static
address 23.226.214.199
netmask 255.255.255.224

Then reboot VPS by typing below via SSH

sudo reboot

هل كانت المقالة مفيدة ؟

 طباعة

اقرأ أيضاً :

How to add LAMP support to Ubuntu 14.0.4 64-bit on New OpenVZ

A LAMP (Linux, Apache, MySQL, PHP) stack is a common web stack used for hosting web content. This...

How to fix NoVNC Console Just Black Screen

Debian 5,6,7 This will also work in debian8 if you use sysv-init instead of systemd Editing the...

How to reinstall your OS

1. Login to client area2. Go to your Active services you want to reinstall -> click View...

New template network/ssh down

We just made aware that the new LXC plan template and some new openvz plans, the network/sshd may...

How to setup OpenVPN on Ubuntu 14.04

Please see https://help.ubuntu.com/14.04/serverguide/openvpn.html