Manually adding an additional IP to a specific network device

Материал из Webko Wiki
Перейти к навигации Перейти к поиску

If you need to manually add an IP to your device, so that it's added by the system ("network" script), and not DA ("startips" script), you can do so by adding a network-script for the new IP. This guide is only for Redhat/Fedora/CentOS based systems. See this guide for other systems.

We'll use an IP example of 1.2.3.4, so replace all instances of that value with your own IP.

1) First we need to know on which device to add the additional IP. Most of the time, it will be eth0, but not always. Type:

/sbin/ifconfig

to get a listing of your current devices. See which device your server IP is using (Eg: eth0), then for your additional IP, you'll just add another number to it with a colon, eg: eth0:0

2) Create the actual network-scripts file:

cd /etc/sysconfig/network-scripts
nano ifcfg-eth0:0

3) In that file, add the following code:

DEVICE=eth0:0
BOOTPROTO=none
ONPARENT=yes
IPADDR=1.2.3.4
NETMASK=255.255.255.255
ONBOOT=yes

where you chop off the last number from the IP. Save/exit.

4) Restart your network and pray it works:

/etc/init.d/network restart
/etc/init.d/startips start

the "startips" script is just for the DA controlled IPs. You need to run it after restarting your network to load all DA controlled IPs. Your own IP should have been loaded into the device with the "netwrok restart" step.

5) Confirm it's loaded by checking ifconfig again:

/sbin/ifconfig