Using a VyOS Router with Hyper-V

Please share with your friends...
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

Virtual Machines

To use the VyOS router with your Virtual Machines, you simply need to connect their network adapters to the VyOS router private switch, and then optionally set the desired VLAN IDs.

Windows PowerShell

  1. Connect your virtual machine to the VyOS router, using the following command:
    Connect-VMNetworkAdapter -SwitchName "VyOS Router" -VMName "New Virtual Machine"

    Replace the values for SwitchName and VMName with your own corresponding values.

  2. Enable VLAN identification to tag all network communications through this network adapter, using the following command:
    Set-VMNetworkAdapterVlan -VMName "New Virtual Machine" -Access -VlanId 2

    Replace values for VMName and VlanId with your own corresponding values. Without this optional command, the virtual machine will be located in the Untagged VLAN.

Hyper-V Manager

  1. Open Settings for the Virtual Machine.
    Enable virtual LAN identification

    Enable virtual LAN identification

  2. From the Settings windows, perform the following actions:
    1. Click the Virtual switch drop down list, and select VyOS Router;
    2. Tick Enable virtual LAN identification;
    3. Type the VLAN identifier that this virtual machine will use for all network communications through this network adapter; and
    4. Click OK.

Please share with your friends...
  • 1
  •  
  •  
  •  
  •  
  •  
  •  
  •  
  •  
    1
    Share

7 comments

  1. Hey Chris,
    Nice work! Easy to follow as well. I’ve been doing something similar with 2012R2 Routing and Remote Access with VLANs but I have 2 x hosts running 2012R2 (both with a single NIC) and then have three VLANs that need to be routed. I needed both hosts to be in the domain so I can configure constrained delegation and move VMs between hosts. Have you tried this config on two hosts?

    1. Hi Martin!

      Thanks for you comments 🙂 What you are currently doing with RRAS should be quite easy with VyOS – although I haven’t specifically tried it.

      Kind Regards,
      Chris.

  2. Hi Chris,

    It works! Just started learning VyOs and this guide helps me a lot!
    Thank you very much.

    wks_adm

  3. Hi Chris,

    It is possible that I can communicate with the VM into my local machine? I tried to use the Internal Network adapter but I can’t ping the VM’s IP. Thank you in advance.

    1. Hi wks_adm,

      The VyOS configuration presented in the tutorial uses NAT in the same way as a home broadband router, so by default it is not possible for your host machine on the “outside” to communicate with a virtual machine on the “inside”. However, like a router, in VyOS you can setup port forwarding (Desination NAT) – so you can manually setup rules to allow individual outside connections through.

      For example, the following commands enable port forwarding for RDP (TCP 3389) to host 172.16.1.20:

      set nat destination rule 10 description 'RDP to 172.16.1.20:3389'
      set nat destination rule 10 destination port 3389
      set nat destination rule 10 inbound-interface eth0
      set nat destination rule 10 protocol tcp
      set nat destination rule 10 translation address 172.16.1.20
      set nat destination rule 10 translation port 3389

      RDP to the VyOS eth0 external address. Use different destination port addresses for multiple hosts with the same service.

      Hope that helps!
      Chris.

  4. Hi Chris,

    Fantastic! I was looking this for kind of tutorial, I followed all the instructions and it works like a Charm
    Thank you very much for spending your time making this great tutorial.

Leave a Reply