VMware supports VLAN tagging by Virtual Machines, this feature is called a guest VLAN tagging. GVT support depends on a Guest OS installed. Some OSs support VLAN tagging natively as long as NIC driver is available. Others require NIC driver for vNIC. VMXNET3 driver for Windows support VLAN tagging from Guest OS, so you can insert VLAN ID.
This is what I want to achieve here. I want to configure standard vNetwork Switch to have VLAN 2001 and 2002 and VMs in each VLANs to communicate each other.
VMware network configuration
Configuring Standard vNetwork Switch for GVT
If you are using vNetwork Standard Switch, you will need to configure a Port Group for VLAN 4095. VLAN 4095 is special VLAN ID reserved for GVT. This will effectively makes a port group as a VLAN trunk port.
Step 1
Create an Virtual Machine Port Group
Step 2
Enter VLAN ID as 4095. as you can see from the screenshot, as soon as you enter 4095 it will automatically recognise this and make it to All(4095)
Step 3
Verify VLAN 4095 port group
Now I have a trunk port configured on vNetwork Standard Switch. Then I need to create a Virtual Machine uses this port group. (I called it Trunk)
I have installed Ubuntu Server as a guest OS, and configured VLAN interfaces.
Configuring VLAN Interfaces on Ubuntu Server
Step 1
Using vconfig command on Ubuntu Server create VLAN 2001 and 2002.
root@VM-Router-Trunk:/home/root# vconfig add eth1 2001 Added VLAN with VID == 2001 to IF -:eth1:- root@VM-Router-Trunk:/home/root# vconfig add eth1 2002 Added VLAN with VID == 2002 to IF -:eth1:-
Step 2
Assign IP Address to each sub interface
root@VM-Router-Trunk:/home/root# ifconfig eth1.2001 10.200.1.254 netmask 255.255.255.0 broadcast 10.200.1.255 up root@VM-Router-Trunk:/home/root# ifconfig eth1.2002 10.200.2.254 netmask 255.255.255.0 broadcast 10.200.2.255 up
Step 3
Verify IP Addresses are configured properly.
root@VM-Router-Trunk:/home/root# ifconfig eth1 Link encap:Ethernet HWaddr 00:50:56:ba:7e:01 inet6 addr: fe80::250:56ff:feba:7e01/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:41 errors:0 dropped:1 overruns:0 frame:0 TX packets:18 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:3669 (3.6 KB) TX bytes:1404 (1.4 KB) eth1.2001 Link encap:Ethernet HWaddr 00:50:56:ba:7e:01 inet addr:10.200.1.254 Bcast:10.200.1.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:feba:7e01/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:468 (468.0 B) eth1.2002 Link encap:Ethernet HWaddr 00:50:56:ba:7e:01 inet addr:10.200.2.254 Bcast:10.200.2.255 Mask:255.255.255.0 inet6 addr: fe80::250:56ff:feba:7e01/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:6 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 B) TX bytes:468 (468.0 B)
Step 4
Verify that VLAN ID is associated to each sub interface.
root@VM-Router-Trunk:/home/root# cat /proc/net/vlan/eth1.2001 eth1.2001 VID: 2001 REORDER_HDR: 1 dev->priv_flags: 1 total frames received 0 total bytes received 0 Broadcast/Multicast Rcvd 0 total frames transmitted 6 total bytes transmitted 468 Device: eth1 INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 EGRESS priority mappings: root@VM-Router-Trunk:/home/root# cat /proc/net/vlan/eth1.2002 eth1.2002 VID: 2002 REORDER_HDR: 1 dev->priv_flags: 1 total frames received 0 total bytes received 0 Broadcast/Multicast Rcvd 0 total frames transmitted 6 total bytes transmitted 468 Device: eth1 INGRESS priority mappings: 0:0 1:0 2:0 3:0 4:0 5:0 6:0 7:0 EGRESS priority mappings:
Step 5
Finally I need to enable Routing on Ubuntu Server. As Routing is disabled by default.
root@VM-Router-Trunk:/home/root# cat /proc/sys/net/ipv4/ip_forward 0 root@VM-Router-Trunk:/home/root# echo 1 > /proc/sys/net/ipv4/ip_forward root@VM-Router-Trunk:/home/root# cat /proc/sys/net/ipv4/ip_forward 1
Test Inter-VLAN Routing
Now let test Inter-VLAN routing. I have 2 Linux Machines for this testing
Step 1
Configuring VLAN 2001 and 2002 on vNetwork Standard Switch
Step 2
Configure 2 Linux VMs to use these Port Groups
VM in VLAN 2001
VM in VLAN 2002
Step 3
Configure IP Addresses on these Linux VMs
VM in VLAN 2001 (10.200.1.1)
root@ttyp1[root]# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:BA:7E:03 inet addr:10.200.1.1 Bcast:10.200.1.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:71 errors:0 dropped:0 overruns:0 frame:0 TX packets:56 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:7851 (7.6 KiB) TX bytes:8202 (8.0 KiB) Interrupt:11 Base address:0x2000
VM in VLAN 2002 (10.200.2.1)
root@ttyp1[root]# ifconfig eth0 Link encap:Ethernet HWaddr 00:50:56:BA:7E:04 inet addr:10.200.2.1 Bcast:10.200.2.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:114 errors:0 dropped:0 overruns:0 frame:0 TX packets:78 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:11927 (11.6 KiB) TX bytes:10910 (10.6 KiB) Interrupt:11 Base address:0x2000
Step 4
Verify the connectivity.
From VM in VLAN 2001 to VM in VLAN 2002
root@ttyp1[root]# ping 10.200.2.1 PING 10.200.2.1 (10.200.2.1): 56 data bytes 64 bytes from 10.200.2.1: icmp_seq=0 ttl=63 time=0.4 ms 64 bytes from 10.200.2.1: icmp_seq=1 ttl=63 time=0.4 ms 64 bytes from 10.200.2.1: icmp_seq=2 ttl=63 time=0.4 ms 64 bytes from 10.200.2.1: icmp_seq=3 ttl=63 time=0.4 ms --- 10.200.2.1 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.4/0.4/0.4 ms
From VM in VLAN 2002 to VM in VLAN 2001
root@ttyp1[root]# ping 10.200.1.1 PING 10.200.1.1 (10.200.1.1): 56 data bytes 64 bytes from 10.200.1.1: icmp_seq=0 ttl=63 time=2.1 ms 64 bytes from 10.200.1.1: icmp_seq=1 ttl=63 time=0.5 ms 64 bytes from 10.200.1.1: icmp_seq=2 ttl=63 time=0.3 ms 64 bytes from 10.200.1.1: icmp_seq=3 ttl=63 time=0.3 ms --- 10.200.1.1 ping statistics --- 4 packets transmitted, 4 packets received, 0% packet loss round-trip min/avg/max = 0.3/0.8/2.1 ms
VMware KB :
Configuring Virtual Guest VLAN tagging (VGT) mode on a vNetwork Distributed Switch