Adding More or Additional Ip in Your Linux Box

Bullten

Member
Many Web Hosting Company providing UnManaged Server counts adding additional Ip in linux distro as managed service and can charge you dollars for it. To rest that aside we have come up with a tutorial so that anyone can easily add N number of ip in Linux Dedicated Server or VPS Server.

How to Ad Ip Address

First, Login as root through ssh and change the current working directory to /etc/sysconfig/network-scripts

Code:
cd /etc/sysconfig/network-scripts

Second, find what network adapter is currently been used in your server:

Code:
ls ifcfg-*

Active-Network-Interface.png


Third, In the above figure you can see ifcfg-eth0 ifcfg-lo ifcfg-venet0 are shown but one must be your working adapter. To find that out use the command below

Code:
ifconfig

eth0-setting.png


In above figure your can see your Ethernet eth0 is having your server main ip address. So we will configure using that.

Fourth, you have to make a clone of etho and name it as eth0:0 using the command below

cp ifcfg-eth0 ifcfg-eth0:0

Fifth, edit ifcfg-eth0:0 and change DEVICE to eth0:0 and change IPADDR to new ip address you want to add. See the picture below:

Ethernet-setting.png


Sixth, Now everything is done and you just need to take the ip address live using the command below

Code:
ifup eth0:0

Added-Network-IP%27s.png


Just follow step fourth to sixth to add N numbers of ip’s by adding n number of interface to your server.

If you hang somewhere feel free to contact our support.
 
If you run CPanel or a system like that make sure you do it via the panel or you will likely mess stuff up. We've seen it happen to where things can get glitchy.
 
Yes, if you using the plain server than "Bullten" users steps is perfect for you and if you are using the control panel than its always better to add ip by using the control panel because control panel linked the ips in the different files to implement with the server and control panel settings...
 
I'd add that this is for RedHat/CentOS type of distributions.

This won't work if you have a Debian or Ubuntu type.
 
For adding via SSH and using Ubuntu/Debian:

You'll have to edit the following file: /etc/network/interfaces, use whichever editor you like.
I will use the IP: 192.168.1.10 as my main IP. I will want to add the IP: 192.168.1.11.


auto lo
iface lo inet loopback


auto eth0
iface eth0 inet static


address 192.168.1.10
netmask 255.255.255.0
broadcast 192.168.1.255
gateway 192.168.1.1

Just go ahead and skip down to a new line of the file. Next add this: (Change the address, netmask and broadcast to your own)

auto eth0:0
iface eth0:0 inet static

address 192.168.1.11
netmask 255.255.255.0
broadcast 192.168.1.255

Next restart networking by running /etc/init.d/networking restart. Do a ifconfig to see if you see the new ip as eth0:0.
If you want to add more than one ip, just go ahead and do the same except just put iface eth0:1 instead of iface eth0:0

Fedora/CentOS:
cd into /etc/sysconfig/network-scripts
Make multiple copies of ifcfg-eth0 and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.
Open each of them and at least change the IPADDR to your chosen IP address and the NETMASK to the subnet mask for that IP address.
Example:

DEVICE=eth0:0
BOOTPROTO=static
IPADDR=192.168.1.11
NETMASK=255.255.255.0
ONBOOT=yes

Restart the network:
/sbin/service network restart
 
Hello,

If you are using WHM sever then you will find the easy option to add a new IP address in your server WHM --> IP functions--> Add new ip address.
 
Just about anything with a panel I wouldnt add this way but standard box, the above tutorials will work. Back in my newbie days I followed a similar tutorial that came in mail after ip allocation from softlayer and totally messed things up. SO its always good to check everything you got going on first.
 
If you are using OpenVZ or Xen VPS the IPs are added from the hosting provider to your server via admin panel.
 
Top