- Linux Systems
- Network Turorial On How To Add Virtual Ip Address To Linux
This Page Contains information about Network Turorial On How To Add Virtual Ip Address To Linux By wallpaperama in category Linux Systems with 12 Replies. , Last Updated: Tue Feb 07, 2023
Fri Jan 09, 2009
on this post i will teach you how you can add an additional ip interface address to your linux server. we will be adding ip 10.0.0.2
lets say we already have binded our ip of 10.0.0.1 in our NIC which is ETH0 on this step by step tutorial guide i will show you how you can add anothre ip address to the same interface but it will be a virtual interface. this will be very easy using ssh. so login to your server with root acess or as a super user.
NOTE: i am using a red hat fedora core system for this example, i think is should work on centos but not sure about other distributions like ubuntu or debian
the first command is going to make a copy of the current interface:
cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0
now that we have a copy of our new virtual interface, you need to edit the file:
NOTE: i am using nano as my text editor, im sure you can use whatever your favorite text editor is. like VI for example
ok, when you first open ifcfg-eth0:0 it will probably look like this:
ETHTOOL_OPTS="duplex full speed 100 autoneg off wol g"
now, change the following lines/fields to match the new virtual ip:
On my sample here, i only change DEVICE and IPADDR
now that our new virtual interface it configured, its time to make the changes work, how do we do that.. we do that by restarting our network. so send this unix shell command to restart our network in our server
service network restart
or another way to restart your network is with this command:
ok, if you are going through ssh, wait like 10 seconds the if the changes took affect and there were no problems, it should work ok. if you get disconnected, try to connect to your ssh session again.
now that the network has been restarted, you can test it by pinging your new virtual ip
after you ping you should get successful ping like this:
PING 10.0.0.2 (10.0.0.2) 56(84) bytes of data.
64 bytes from 10.0.0.2: icmp_seq=1 ttl=64 time=0.018 ms
64 bytes from 10.0.0.2: icmp_seq=2 ttl=64 time=0.018 ms
64 bytes from 10.0.0.2: icmp_seq=3 ttl=64 time=0.021 ms
64 bytes from 10.0.0.2: icmp_seq=4 ttl=64 time=0.019 ms