2

I noticed that IP forwarding appears to be enabled in WSL (Windows 10pro 1709), according to sysctl. I'm hoping I can use this to make a software router on WSL -- to play with Hyper-V VM traffic on the same physical host. The VM and the host can communicate over a shared /24 ipv4 subnet.

Ideally, I'd want to use WSL to configure iptables-like rules, or have some sort of software router program using RAW sockets that could rewrite traffic.

# on the WSL bash
$ sysctl net.ipv4.ip_forward
net.ipv4.ip_forward = 1

My windows host and the VM are both in 192.168.4.X. 192.168.4.215 is the host. 192.168.4.228 is the VM.

I've added a rule to the windows firewall to allow every incoming TCP port on that subnet, and tested connectivity by transferring web pages served by the WSL host and downloaded by the VM. (e.g. ran python -m SimpleHTTPServer in wsl and used curl http://192.168.2.215 on the vm)

I've added the windows host as the default gateway inside the VM:

# route add default gw 192.168.4.215
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface
0.0.0.0         192.168.4.215   0.0.0.0         UG    0      0        0 eth0
172.17.0.0      0.0.0.0         255.255.0.0     U     0      0        0 docker0
192.168.4.0     0.0.0.0         255.255.255.0   U     0      0        0 eth0

But my TCP connections initiated on the VM are not being routed by Windows (e.g. curl http://<publicip>.). Can't connect

What else do I need to unblock in Windows?

Edit

I've somewhat given up on this. Because all I wanted to do with the VM traffic was to NAT it over the host's VPN tunnel, I ended up using creating a special NAT interface with powershell:

https://serverfault.com/questions/911578/windows-10-pro-as-a-nat-between-two-interfaces

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.