Skip to main content
Tweeted twitter.com/super_user/status/1141813078063034368
added 363 characters in body
Source Link
init_js
  • 375
  • 2
  • 7
  • 17

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

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

I noticed that IP forwarding claims to be enabled in WSL (Windows 10pro 1709). I'd like to make use of that to redirect Hyper-V VM traffic to another interface. The VM and the host share a /24 ipv4 subnet and can communicate. 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?

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

added 156 characters in body; edited title
Source Link
init_js
  • 375
  • 2
  • 7
  • 17

How to use Windows WSL to route ip trafficconfigure routing? Is this possible?

I noticed that IP forwarding claims to be enabled in WSL (Windows 10pro 1709). I'd like to make use of that to redirect Hyper-V VM traffic to another interface. The VM and the host share a /24 ipv4 subnet and can communicate. 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 wslWindows (e.g. curl http://<publicip>.). Can't connect

What else do I need to unblock in Windows?

How to use WSL to route ip traffic

I noticed that IP forwarding claims to be enabled in WSL (Windows 10pro 1709). I'd like to make use of that to redirect Hyper-V VM traffic to another interface. The VM and the host share a /24 ipv4 subnet and can communicate.

# 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 are not being routed by wsl (e.g. curl http://<publicip>.). Can't connect

What else do I need to unblock in Windows?

How to use Windows WSL to configure routing? Is this possible?

I noticed that IP forwarding claims to be enabled in WSL (Windows 10pro 1709). I'd like to make use of that to redirect Hyper-V VM traffic to another interface. The VM and the host share a /24 ipv4 subnet and can communicate. 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?

Source Link
init_js
  • 375
  • 2
  • 7
  • 17

How to use WSL to route ip traffic

I noticed that IP forwarding claims to be enabled in WSL (Windows 10pro 1709). I'd like to make use of that to redirect Hyper-V VM traffic to another interface. The VM and the host share a /24 ipv4 subnet and can communicate.

# 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 are not being routed by wsl (e.g. curl http://<publicip>.). Can't connect

What else do I need to unblock in Windows?