Linux – Hyper-v Virtual Network Switch Configuration

centoscentos6hyper-vlinuxnetworking

I have Hyper-v Running. What I am trying to do is setup a CentOS firewall box which will forward all traffic to the 2nd VM CentOS box which has an internal adapter and only seen by the 1st VM Box(firewall box).

In Hyper-V you can setup external, internal, and private Virtual Switches. So what I did was setup a Virtual Switch and set it's VLAN ID to 5. On the other 2 Virtual Adapters which are connected to the Virtual Switch I set them to VLAN ID 5 as well.

I am just confused as to how do I create and setup an internal network between these two VMs using the Virtual Switch.

Best Answer

First Hyper-V Switches do not have a VLAN ID. Hyper-V switches belong to all VLANs. You assign a VLAN to the virtual adapters with VMs and the virtual adapters created for management.

For the sake of simplicity you should generally stick with a single Virtual Switch unless you really need to segregate traffic.

So basically you should setup your External switch, and link it to whatever interfaces you are using for VM traffic.

In your firewall VM you should have two virtual adapters, the virtual adapter you wall use as the outside adapter should be set to the default VLAN, or whatever VLAN you are using for your VMs. It will depend on the configuration of you physical adapters and switch port you are connected with. If you are not doing VLAN trucking on the switch port you are connected with, this should be the default LAN.

The inside adapter from your firewall, and the adapter on the VM that can both be connected the external switch, and they should be be assigned a VLAN ID different from the VLAN assigned to the external adapter of your firewall. This VLAN probably shouldn't already exist on your external network.

So assuming the switch your Hyper-V box connects to isn't doing any trunking and the un-tagged VLAN is the one you want to access your setup would be like this.

  • Hyper-V switch associated with your physical adapters.
  • Firewall VM
    • External adapter left to default VLAN
    • Internal adapter set to a VLAN 30
  • Inside host
    • Adpater set to VLAN 30
Related Topic