0

I have a QEMU VM with Windows 10 from which I can connect to a VPN. I would like to connect also the guest system (GNU/Linux) to the VPN, but unfortunately the VPN works only on Windows.

I use virt-manager to manage my VM.

1 Answer 1

1

Here there is a solution for virtualbox: https://stackoverflow.com/questions/53573337/how-to-share-guest-vms-vpn-connection-with-host

It could be easily adapted for QEMU following https://brockmcelroy.com/kvm-host-only and https://serverfault.com/questions/929081/how-can-i-enable-packet-forwarding-on-windows

  1. Create a Windows VM with virt-manager
  2. On virt-manager main window right click on QEMU/KVM → Deatils → Add newtwork (+)
    • name: host-only
    • mode: Isolated
    • IPv4 config:
      • Network: 192.168.56.0/24
  3. In the VM hardware details of virt-manager press Add hardware below → Network
    • Network source: the previosly created host-only isolated network
  4. Reboot the host (the Unix-like machine)
  5. In the guest (the Windows VM) open the registry editor and under HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\Tcpip\Parameters edit/create the DWORD IPEnableRouter setting it to 1
  6. Reboot the guest
  7. In the guest open Network & Internet SettingsNetwork and Sharing Center.
    Here there are two networks: the NAT one (with internet access) and the host-only one (without internet access): open the latter → Properties → Internet Protocol Version 4 (TCP/IPv4) → Properties
    • IP address: 192.168.56.2
  8. Install on the guest the VPN and connect to it
  9. In the guest open Network & Internet SettingsNetwork and Sharing Center.
    Open the VPN network → Properties → Sharing → Allow with the host-only network
  10. In the host run ip route add xxx.yyy.zzz.www/qq via 192.168.56.2 with sudo (where xxx.yyy.zzz.www/qq is the network you want to access through the VPN)

On guest restart

  • Check the IP of the host-only network to be correct (step 7 above)
  • Disbale the sharing of the VPN network and re-enable it (step 9 above), after connecting to the VPN

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .