Simulating Multiple NICs
This article discusses a way to simulate multiple network interface cards on a computer by using a managed switch and subinterfaces in Linux. This article is in part a continuation of the article about connecting to a switch by trunk port.
Configuring the Switch
In drawing from the previous article, I will use a trunk port to connect from the switch to the computer, and then configure all the other ports to initially be in VLAN 2.
(config)# int f0/1 (config-if)# switchport mode trunk (config-if)# switchport nonegotiate (config-if)# swtichport trunk native vlan 2 (config-if)# int range f0/2 - 24 (config-if-range)# switchport mode access (config-if-range)# switchport nonegotiate (config-if-range)# switchport access vlan 2
I then assign different ports to different VLANs. Each one of these ports can then act as a virtual interface on the computer.
(config)# int f0/2 (config-if)# switchport access vlan 10 (config-if)# int f0/3 (config-if)# switchport access vlan 11 (config-if)# int f0/4 (config-if)# switchport access vlan 12 (config-if)# int f0/5 (config-if)# switchport access vlan 13 (config-if)# int f0/6 (config-if)# switchport access vlan 14 (config-if)# int f0/7 (config-if)# switchport access vlan 15 (config-if)# int f0/8 (config-if)# switchport access vlan 16
Configuring the Computer
I can then configure the computer with subinterfaces for each VLAN specified in the switch. Since each VLAN is only associated with one port, that port can be treated like an extended network interface from the computer.
# Native interface auto eth0 iface eth0 inet dhcp # Management interface iface eth0.99 inet static address 192.168.99.100 netmask 255.255.255.0 # Virtual interfaces mapped to switch ports iface eth0.10 inet manual iface eth0.11 inet manual iface eth0.12 inet manual iface eth0.13 inet manual iface eth0.14 inet manual iface eth0.15 inet manual iface eth0.16 inet manual