My VLAN ID is 5. So I need to copy file /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth0.5
# cp /etc/sysconfig/network-scripts/ifcfg-eth0 /etc/sysconfig/network-scripts/ifcfg-eth0.5
So I have one network card (eth0) and it needs to use tagged network traffic for VLAN ID 5.
Above files will configure Linux system to have:
- eth0 - Your regular network interface
- eth0.5 - Your virtual interface that use untagged frames
Do not modify /etc/sysconfig/network-scripts/ifcfg-eth0 file. Now open file /etc/sysconfig/network-scripts/ifcfg-eth0.5 using vi text editor:
# vi /etc/sysconfig/network-scripts/ifcfg-eth0.5
Find DEVICE=ifcfg-eth0line and replace with:
Also make sure you assign correct IP address using DHCP or static IP. Save the file. Remove gateway entry from all other network config files. Only add gateway to /etc/sysconfig/network file.
# /etc/init.d/network restart
Please note that if you need to configure for VLAN ID 2 then copy the copy file /etc/sysconfig/network-scripts/ifcfg-eth0 to /etc/sysconfig/network-scripts/ifcfg-eth0.2 and do the above procedure again.
Here's a sample (ifcfg-eth1.201 in this case):
Doing It Old-School
If you want to define the interface and bring it up without applying an IP to it (for example, if you have a complicated sniffing environment), you have to define the VLAN manually then bring the interface up manually:
# vconfig add eth2 1234
# ifconfig eth2.1234 up
You can now run a packet sniffer on that interface in promiscuous mode.