In the ‘Configuring IP on RedHat‘ post we
considered about how to configure an ip-address to an interface in RHEL6. Now
let’s move another step further and configure a sub interface. Sub interface is
a logical interface which usually allows you to create VLANs.
In the below exercise I will create sub interfaces for the
interface “eth0”. I should provide that
the file ‘ifcfg-eth0’ is already in my system, configured properly and given
the ip-address ‘10.1.1.1’.
First you have to create a file in the same directory
“/etc/sysconfig/network-scripts/” named in a specific format.
Format of the file (if the interface is eth0):
<Interface name> : <sub interface number>
Ex: eth0:100
How to do that?
First go to the director ‘network-scripts’
#cd /etc/sysconfig/network-scripts/
Now you need to copy the ifcfg file you have for eth0 and
rename it as ‘ifcfg-eth0:100’.
#copy ifcfg-eth0 ifcfg-eth0:100
Now you should do tiny adjustments to the newly created file
in order to configure it as a sub-interface.
How to do that?
First open the file in vi editor,
#vi ifcfg-eth0:100
In my case file looks something like below,
DEVICE="eth0"HWADDR="08:00:27:4F:CF:22"NM_CONTROLLED = "no"ONBOOT="yes"IPADDR=10.1.1.1NETMASK=255.255.255.0
First rename the device into “eth0:100”
Then, modify the ip-address.
File will ultimately looks like this.
DEVICE="eth0:100"HWADDR="08:00:27:4F:CF:22"NM_CONTROLLED = "no"ONBOOT="yes"IPADDR=10.1.2.1NETMASK=255.255.255.0
Now save and quit.
Good, you have successfully configured the sub-interfaces
and now it’s time to restart the network adapters.
This can simply done by the
command,
#/etc/init.d/network restart
Now check what you have done by using the ‘ifconfig’
command.
Make sure that you have an entry for the sub-interface
‘eth0:100’.
Thanks.