How to Add IP Addresses to CentOS server

Add newly assigned IP addresses from SSH, follow this procedure:

  • Login to your server with SSH as root.

  • Go to the /etc/sysconfig/network-scripts directory.

cd  /etc/sysconfig/network-scripts/

  • Verify which interface you will use to add IP addresses. Typically, this will be eth0 for public IP addresses.

/sbin/ifconfig

  • Make a copy of ifcfg-eth0 for each IP you wish to add and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.

cp ifcfg-eth0 ifcfg-eth0:0

cp ifcfg-eth0 ifcfg-eth0:1

cp ifcfg-eth0 ifcfg-eth0:2

cp ifcfg-eth0 ifcfg-eth0:3

cp ifcfg-eth0 ifcfg-eth0:4

  • Open each of them and change the fields DEVICE, .IPADDR and NETMASK accordingly.

A sample entry would look like this:

DEVICE=eth0:0

BOOTPROTO=static

IPADDR=34.123.111.21

NETMASK=255.255.255.0

ONBOOT=yes

  • Restart the network:

/etc/init.d/network restart

To verify what are the IP addresses assigned to your server, please use the following command:

/sbin/ifconfigTodd newly assigned IP addresses from SSH, follow this procedure:

  • Login to your server with SSH as root.

  • Go to the /etc/sysconfig/network-scripts directory.

cd  /etc/sysconfig/network-scripts/

  • Verify which interface you will use to add IP addresses. Typically, this will be eth0 for public IP addresses.

/sbin/ifconfig

  • Make a copy of ifcfg-eth0 for each IP you wish to add and name them as ifcfg-eth0:0, ifcfg-eth0:1 etc.

cp ifcfg-eth0 ifcfg-eth0:0

cp ifcfg-eth0 ifcfg-eth0:1

cp ifcfg-eth0 ifcfg-eth0:2

cp ifcfg-eth0 ifcfg-eth0:3

cp ifcfg-eth0 ifcfg-eth0:4

  • Open each of them and change the fields DEVICE, .IPADDR and NETMASK accordingly.

A sample entry would look like this:

DEVICE=eth0:0

BOOTPROTO=static

IPADDR=34.123.111.21

NETMASK=255.255.255.0

ONBOOT=yes

  • Restart the network:

/etc/init.d/network restart

To verify what are the IP addresses assigned to your server, please use the following command:

/sbin/ifconfig


Note: CentOS servers are available as virtual and dedicated servers. You can for example install CentOS 6 or CentOS 7 on a cheap unmetered VPS.

  • 39 Users Found This Useful
Was this answer helpful?

Related Articles

How do I manage my VPS Server?

We provide you with a very simple interface for controlling your VPS hosting with unmetered...

How to install MySQL

Here is a step by step how to install MySQL and secure it for your unlimited bandwidth VPS. You...

How to Install Apache2 and PHP5 on Ubuntu

Installing Apache2 and PHP5 is super simple on Ubuntu: # apt-get install apache2# apt-get...

How to Install MySQL on Ubuntu

Learn how to install MySQL on your DDoS protected dedicated server or DDoS protected VPS if...

Installing Node.js on CentOs 5

Installing node.js on a cheap VPS with unlimited bandwidth is pretty simple. For more information...