CentOS Linux Networking

Add IP to CentOS 5/6

If you recently got a secondary IP block for your server but you do not know how to bind the secondary IP address, please follow the steps below:


First, run the following command to see which interface your server is using:



You will see an output like so:

eth0 Link encap:Ethernet HWaddr 00:0C:29:40:93:9C
inet addr: Bcast: Mask:
RX packets:1771 errors:0 dropped:0 overruns:0 frame:0
TX packets:359 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:138184 (134.9 KiB) TX bytes:49108 (47.9 KiB)
Interrupt:67 Base address:0x2000

lo   Link encap:Local Loopback
inet addr: Mask:
inet6 addr: ::1/128 Scope:Host
RX packets:390 errors:0 dropped:0 overruns:0 frame:0
TX packets:390 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:29204 (28.5 KiB) TX bytes:29204 (28.5 KiB)

In this scenario, you will be looking for the eth0 interface.  Now on to the actual command to bind the secondary ip!  Let’s say you get allocated an additional block of 3 ip addresses:,, with a netmask of, you would do the following:


ifconfig eth0:1 netmask
ifconfig eth0:1 up
ifconfig eth0:2 netmask
ifconfig eth0:2 up
ifconfig eth0:3 netmask
ifconfig eth0:3 up 

If you want the new IP’s to be brought up automatically upon reboots, you can add these commands to the file: /etc/rc.local

That’s all there is to it!

Related Articles

  • Disable SELinux

    Security-Enhanced Linux (SELinux) is a mandatory access control (MAC) security mechanism implemented in the Linux kernel. This mechanism adds an extra layer of access security to your files,directories,devices, ports and...
  • Simple Stateful Load Balancer with iptables and NAT

    NOTE: To demonstrate how iptables can perform network address translation this how-to shows how to use it to implement a over-simplified load balancer. In practice we would use a daemon...
  • How to clear the YUM cache?

    What is yum? The Yellowdog Updater, Modified (yum) is an open-source command-line package-management utility for Linux operating systems using the RPM Package Manager. Yum allows automatic updates, package and dependency...
  • How to List Compiled PHP Modules from the Command Line

    The general command is php -m; this command will give you the full list of extensions: php -m This command will give you an output like: bz2 calendar Core ctype...