How can I route the traffic from OpenVPN, running on a Debian 12 VM, into a Windows 11 VM?
Similar to Whonix, I am trying to set up two virtual machines on a Debian 12 host, in which the first virtual machine (a Debian 12 virtual machine) runs OpenVPN, and routes the traffic that occurs in tun0
(the network device created by OpenVPN) into and out of a seperate Windows 11 virtual machine.
I have spent ~2-3 days attempting to figure it out how to do this, but so far it has been all failure and no success.
I have zero experience with IP configuration, and most of this has been like navigating around in the dark.
I tried creating a bridge on my host machine:
auto bridge0
iface bridge0 inet manual
bridge_ports none
Then passing it to my Debian 12 VM:
<interface type="bridge">
<mac address="52:54:00:1c:be:16"/>
<source bridge="bridge0"/>
<target dev="vnet4"/>
<model type="virtio"/>
<link state="up"/>
<alias name="net2"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x0a" function="0x0"/>
</interface>
And also passing it to my Windows 11 VM:
<interface type="bridge">
<mac address="52:54:00:8f:20:8a"/>
<source bridge="bridge0"/>
<target dev="vnet5"/>
<model type="virtio"/>
<alias name="net0"/>
<address type="pci" domain="0x0000" bus="0x00" slot="0x03" function="0x0"/>
</interface>
Then enabled IP forwarding:
sudo sysctl -w net.ipv4.ip_forward=1
And finally set up the passed bridge in the Debian 12 VM:
auto ens10
iface ens10 inet static
address 192.168.0.10
netmask 255.255.255.0
gateway 192.168.0.1
bridge_ports none
bridge_stp off
After that, I made sure to link both tun0
and ens10
together:
sudo iptables -t nat -A POSTROUTING -o tun0 -j MASQUERADE
sudo iptables -A FORWARD -i tun0 -o ens10 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i ens10 -o tun0 -j ACCEPT
After this, I made sure to restart the networking
and NetworkManager
services:
sudo systemctl restart networking
sudo systemctl restart NetworkManager
With all of this being done, I would then attempt to connect from the Windows 11 VM:
IP assignment: Manual
IPv4 address: 192.168.0.10
IPv4 mask: 255.255.255.0
IPv4 gateway: 192.168.0.1
DNS server assignment: Manual
IPv4 DNS servers: 8.8.8.8 (Unencrypted)
192.168.0.1 (Unencrypted)
And with all of this, I still had no internet access from the Windows 11 VM. I wish to be able to access the internet in that Windows 11 VM as the internet that the OpenVPN connection from the Debian 12 VM provides.
How do I accomplish this?
memey is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.