Configure Additional IP Addresses

By admin at 2017-09-29 • 0 collector • 1615 pageviews

5 Configure Additional IP Addresses

(This section is totally optional. It just shows how to add additional IP addresses to your network interface eth0 if you need more than one IP address. If you're fine with one IP address, you can skip this section.)


Let's assume our network interface is eth0. Then there is a file /etc/sysconfig/network-scripts/ifcfg-eth0 which contains the settings for eth0. We can use this as a sample for our new virtual network interface eth0:0:


cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0:0


Now we want to use the IP address 192.168.0.101 on the virtual interface eth0:0. Therefore we open the file /etc/sysconfig/network-scripts/ifcfg-eth0:0 and modify it as follows (we can leave out the HWADDR line as it is the same physical network card):


vi /etc/sysconfig/network-scripts/ifcfg-eth0:0


# Intel Corporation 82545EM Gigabit Ethernet Controller (Copper)

DEVICE=eth0:0

BOOTPROTO=static

BROADCAST=192.168.0.255

IPADDR=192.168.0.101

NETMASK=255.255.255.0

NETWORK=192.168.0.0

ONBOOT=yes

Afterwards we have to restart the network:


/etc/init.d/network restart


You might also want to adjust /etc/hosts after you have added new IP addresses, although this is not necessary.


Now run


ifconfig


You should now see your new IP address in the output:


[root@server1 ~]# ifconfig

eth0      Link encap:Ethernet  HWaddr 00:0C:29:95:4B:52

          inet addr:192.168.0.100  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1

          RX packets:413 errors:0 dropped:0 overruns:0 frame:0

          TX packets:298 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:1000

          RX bytes:39156 (38.2 KiB)  TX bytes:61756 (60.3 KiB)


eth0:0    Link encap:Ethernet  HWaddr 00:0C:29:95:4B:52

          inet addr:192.168.0.101  Bcast:192.168.0.255  Mask:255.255.255.0

          UP BROADCAST RUNNING MULTICAST  MTU:1500  Metric:1


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:8 errors:0 dropped:0 overruns:0 frame:0

          TX packets:8 errors:0 dropped:0 overruns:0 carrier:0

          collisions:0 txqueuelen:0

          RX bytes:560 (560.0 b)  TX bytes:560 (560.0 b)


Requires Login

Loading...