Add an ip address

Untitled Document

This is a quick guide on adding IPs to a system manually. I would only suggest it if you are not using a control panel, such as cpanel, that has a feature to adds ips. If your main ethernet device is eth1 instead of eth0 simply substitute eth1 for eth0. Other then that should be pretty simple to follow, this should work on any standard redhat/centos based system.


Login as root then do the following to add a new ip address to any linux redhat based system. If you have cpanel there is a nice little ip management script that just lets you do it via WHM. For those without cpanel do the following: 

cd /etc/sysconfig/network-scripts

Then as a usual precaution I would make a backup of the file
cp ifcfg-eth0 ifcfg-eth0.bak
(you wont need to do anything with the backup)

Then copy the config for your new IP
cp ifcfg-eth0 ifcfg-eth0:1

Then we need to edit the new config
pico -w ifcfg-eth0:1

The lines you need to change:

DEVICE="eth0"
to
DEVICE="eth0:1"

Then change the
IPADDR="xxx.xxx.xxx.xxx"
to be your NEW ip address (it will have your primary ip listed)

Once this is done, press CTRL + X
then press Y and <enter>

This will have saved the config for you and the interface is ready to be brought up. This is done with
/sbin/ifup eth0:1

Having done this if you type
/sbin/ifconfig

You should see something like
------code------
eth0 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:xxx.xxx.xxx.xxx Bcast:xxx.xxx.xxx.xxx Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:55818546 errors:0 dropped:0 overruns:0 frame:0
TX packets:46167836 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:3299680715 (3146.8 Mb) TX bytes:1890963825 (1803.3 Mb)
Interrupt:11 Base address:0xd000

eth0:1 Link encap:Ethernet HWaddr 00:00:00:00:00:00
inet addr:NEW.IP.ADDRESS Bcast:xxx.xxx.xxx.xxx Mask:255.255.254.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:11 Base address:0xd000

lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:241244 errors:0 dropped:0 overruns:0 frame:0
TX packets:241244 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:66571100 (63.4 Mb) TX bytes:66571100 (63.4 Mb)
------/code------

If you then try to ping your new ip it should all work fine 
This should also restart eth0:1 on a reboot as its a direct copy of the eth0 config. So checking for the ONBOOT="yes" in ifcfg-eth0:1 will ensure it DOES come back up on a reboot.


This guide was originally posted at: http://forums.rackshack.net/showthread.php?s=4834c29624a4755c87defe9fa144c29a&threadid=19915&highlight=eth01

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

How to change PRIMARY IP on the server?

Hi,

Thank you for the how-to. Btw, you may consider to add eth0-range instead of eth0:1, eth0:2 and so on.
When IPs are given by blocks -range works just better.

The question I have to you... Is it possible to update PRIMARY IP on the server? The reason is simple - damn SORBS blocked our main IP and we need to change it to new one from the pool we have.

I guess it should be enough to update IPADDR at /etc/sysconfig/network-scripts/ifcfg-eth0 and update IP which points to hostname at /etc/hosts. Then finally update cPanel files - /etc/ips and /etc/wwwacct.conf

May you confirm that it will works?..

main ip update

Physically updating the config files is good. If you update /var/cpanel/users/ /etc/httpd/conf/httpd/conf wwwacct.conf and the named files you probably are good but I have not tested it. There should also be a tool within WHM to change a sites IP.

Powered by Drupal - Theme created by Danger4k