Login

Forgot password?

We love free and open web!

Author Topic: Adding an extra IP address to your CentOS server  (Read 93654 times)

Offline Administrator

  • Administrator
  • Jr. Member
  • *****
  • Posts: 88
    • View Profile
Adding an extra IP address to your CentOS server
« on: November 11, 2011, 08:43:25 PM »
If you have a dedicated server or a VPS and you ordered additional IP addresses for your VPN Server, just follow the following instructions in adding IP address to your server.


Code: [Select]
cd /etc/sysconfig/network-scripts
Then as a usual precaution I would make a backup of the file
Code: [Select]
cp ifcfg-eth0 ifcfg-eth0.bak(you wont need to do anything with the backup)

Then copy the config for your new IP
Code: [Select]
cp ifcfg-eth0 ifcfg-eth0:1
Then we need to edit the new config
Code: [Select]
vim ifcfg-eth0:1You can use any text editors you want.

The lines you need to change:
Quote
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 ESC then type :wq and press enter to save changes

This will have saved the config for you and the interface is ready to be brought up. This is done with
Code: [Select]
/sbin/ifup eth0:1
Having done this if you type
Code: [Select]
/sbin/ifconfig
You should see something like
Code: [Select]
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)

To add more IP Addresses just repeat the steps above and just increment 1 in eth0:1 to eth0:2