14:49 21/05/2015
#HowTo: Configure Linux Virtual Local Area Network (VLAN)
#########################################################
#I needed a physical machine with one NIC to be able to have two different IP addresses on two different VLAN’s.
#This is the scenario:
######################
+++One network card with an IP of 192.168.10.1 (VLAN 10).
+++I needed another interface on the same physical NIC with an IP address of 192.168.20.x (VLAN 20).
#First you copy the network configuration
#cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.10
#My original file looked like this:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=192.168.10.1
USERCTL=no
PEERDNS=yes
TYPE=Ethernet
IPV6INIT=no
#I needed to add in the VLAN info and change the device name (add VLAN=yes)
DEVICE=eth0.10
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=192.168.10.1
USERCTL=no
PEERDNS=yes
TYPE=Ethernet
IPV6INIT=no
#I then copied the file again to my second interface
cp /etc/sysconfig/network-scripts/ifcfg-eth0.10 /etc/sysconfig/network-scripts/ifcfg-eth0.20
#and changed the IP address and device name
DEVICE=eth0.20
ONBOOT=yes
VLAN=yes
BOOTPROTO=none
NETMASK=255.255.255.0
IPADDR=192.168.20.1
USERCTL=no
PEERDNS=yes
TYPE=Ethernet
IPV6INIT=no
#I then removed the original IP address information from
#nano /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
USERCTL=no
PEERDNS=yes
TYPE=Ethernet
IPV6INIT=no
(OLD VALUE):
#My original file looked like this:
DEVICE=eth0
ONBOOT=yes
BOOTPROTO=none
NETMASK=255.255.255.0 #remove
IPADDR=192.168.10.1 #remove
USERCTL=no
PEERDNS=yes
TYPE=Ethernet
IPV6INIT=no
#And restart the network service
service network restart
#Of course the configuration has to be done as well on the switch side as well to allow the trunk of both VLAN’s
Switch#(config)interface Gi3/41
Switch#(config-if)no switchport mode access
Switch#(config-if)switchport mode trunk
Switch#(config-if)switchport trunk allowed vlan 10,20
#Source: http://technodrone.blogspot.com/2011/10/enabling-vlan-tagging-on-redhat-linux.html
# http://www.cyberciti.biz/tips/howto-configure-linux-virtual-local-area-network-vlan.html
#Using the vconfig command
#The vconfig program allows you to create and remove vlan-devices on a vlan enabled kernel. Vlan-devices are virtual Ethernet devices which represents the virtual lans on the physical lan. This is yet another method of configuring VLAN. To add VLAN ID 5 with following command for eth0 interface:
vconfig add eth0 5
No comments:
Post a Comment