Need to create a Ethernet Subinterface on the VM :
The IP configurations on the Red Hat distribution of the Linux operating system are stored in the directory /etc/sysconfig/network-scripts/.
Each interface, as well as sub-interface, requires a unique configuration file.
The below example assigns the interface eth0 an IP address of 192.168.1.42 on a class C network with 192.168.1.1 as the gateway.
/etc/sysconfig/network-scripts/ifcfg-eth0:
DEVICE=eth0
IPADDR=192.168.1.42
NETMASK=255.255.255.0
ONBOOT=yes
GATEWAY=192.168.1.1
In order to assign multiple IP addresses on the same interface (eth0), there must be a configuration file for the sub-interface eth0:0 (incrementing as necessary). The below example will add three more IP addresses to the same interface:
/etc/sysconfig/network-scripts/ifcfg-eth0:0:
DEVICE=eth0:0
IPADDR=192.168.1.41
NETMASK=255.255.255.0
ONBOOT=yes/etc/sysconfig/network-scripts/ifcfg-eth0:1:
DEVICE=eth0:1
IPADDR=192.168.1.44
NETMASK=255.255.255.0
ONBOOT=yes/etc/sysconfig/network-scripts/ifcfg-eth0:2:
DEVICE=eth0:2
IPADDR=192.168.1.45
NETMASK=255.255.255.0
ONBOOT=yesPreviously Configured Sub-Interface :
# Advanced Micro Devices [AMD] 79c970 [PCnet32 LANCE]
DEVICE=eth0:3
BOOTPROTO=static
ONBOOT=yes
HWADDR=00:0c:29:fa:da:13
IPADDR=192.168.1.45
NETMASK=255.255.255.0
NETWORK=192.168.1.0
BROADCAST=192.168.1.253
Note that a gateway statement is not necessary in this file because the same gateway was defined in /etc/sysconfig/network-scripts/ifcfg-eth0.
To update your system’s IP configuration after making changes to the /etc/sysconfig /network-scripts/ directory, execute:
# service network restart
Bring Interfaces UP without restarting network services.sudo ifup eth0:0
sudo ifup eth0:1
sudo ifup eth0:2
sudo ifup eth0:3
Comments
(There are currently no comments for this post.)