Technical Forums > VPN How tos / Tutorials
Adding an extra IP address to your CentOS server
(1/1)
Administrator:
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: ---cd /etc/sysconfig/network-scripts
--- End code ---

Then as a usual precaution I would make a backup of the file

--- Code: ---cp ifcfg-eth0 ifcfg-eth0.bak
--- End code ---
(you wont need to do anything with the backup)

Then copy the config for your new IP

--- Code: ---cp ifcfg-eth0 ifcfg-eth0:1
--- End code ---

Then we need to edit the new config

--- Code: ---vim ifcfg-eth0:1
--- End code ---
You can use any text editors you want.

The lines you need to change:

--- Quote ---DEVICE="eth0"
to
DEVICE="eth0:1"
--- End quote ---

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: ---/sbin/ifup eth0:1
--- End code ---

Having done this if you type

--- Code: ---/sbin/ifconfig
--- End code ---

You should see something like

--- Code: ---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)

--- End code ---

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

Go to full version