Manually adding an additional IP to a specific network device


Enter Your Query:
Use '%' for wildcards and quotes for "exact phrases"


Top Level » System Level

Manually adding an additional IP to a specific network deviceLast Modified: May 1, 2017, 2:23 am
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 , 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

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





Debian

Although we don't have much testing for this with Debian, try editing:

/etc/network/interfaces

and at the bottom of the file (assuming you already have eth0 listed there), add eth0:0:

auto eth0:0
allow-hotplug eth0:0
iface eth0:0 inet static
   address 1.2.3.4
   netmask 255.255.255.0

Once set, then type

ifup eth0:0

As mentioned, this has very limited testing, so be very sure that the setting you're adding are correct.   It's possible the box can become inaccessible if an error is made at this point (which is why we can't do this for you)



FreeBSD ALPHA testing

Assuming your main device name is
Type:

ifconfig em0 1.2.3.4 netmask 255.255.255.255 alias

which should load the IP into the em0 device.  Once confirmed that this worked, edit:

/etc/rc.conf

and below the line that starts with:

ifconfig_em0=...

you'd add an alias line, that looks like this:

ifconfig_em0_alias0="inet 1.2.3.4 netmask 255.255.255.255"





Related Errors

If you get the error:

Error, some other host already uses address 1.2.3.4

then add this line to your ifcfg-eth0:0 file:

ARPCHECK=no



Error:

Error: Connection activation failed: The connection is not for this device.

Solution, add this to your ifcfg file:

NM_CONTROLLED=no

 
Related Helpfiles
My IPs are not being loaded into the network device after bootup or network restarts

2003 JBMC Software, Suite 173  3-11 Bellerose Drive, St Albert, AB  T8N 1P7  Canada.  Mon-Fri 9AM-5PM MST