https://learn.microsoft.com/en-us/windows/wsl/wsl-config#network-settings
[boot]
systemd=true
[network]
generateResolvConf=true
generateResolvConf=true
is the key to restore default /etc/resolv.conf
.
And then:
wsl.exe --shutdown
# or
sudo reboot
$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.29.64.1
$ ip route
default via 172.29.64.1 dev eth0 proto kernel
172.29.64.0/20 dev eth0 proto kernel scope link src 172.29.70.49
$ route -n
Kernel IP routing table
Destination Gateway Genmask Flags Metric Ref Use Iface
0.0.0.0 172.29.64.1 0.0.0.0 UG 0 0 0 eth0
172.29.64.0 0.0.0.0 255.255.240.0 U 0 0 0 eth0