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. is the host. 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 on the vm)

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

# route add default gw
# route -n
Kernel IP routing table
Destination     Gateway         Genmask         Flags Metric Ref    Use Iface         UG    0      0        0 eth0     U     0      0        0 docker0   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?


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:


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.