GWSL-Source
GWSL-Source copied to clipboard
Support manually configured resolv.conf
GWSL currently relies on WSL automatically setting the default gateway IP in /etc/resolv.conf
. /etc/resolv.conf
cannot be relied upon in cases where a user has set network.generateResolvConf = false
in their /etc/wsl.conf
, in order to override their /etc/resolv.conf
(eg. https://github.com/microsoft/WSL/issues/5336).
This PR uses ip route show default
to get the default gateway IP instead.
Possibly resolve #97 too.
Hey hmnd. Thanks for the PR. This is a good idea but unfortunately I have already tried pushing a change like this and it broke more than it fixed. At this point I doubt that there is a one size fits all solution. The current solution seems to fit most configurations. The best fit for a change like this may be in the manual for people to adjust their configurations if need be.
However, it is true that I do not understand WSL networking completely. I think it is wise to stay on the safe side.
FYI as a VPN user on Windows 10, I had to edit my /etc/resolv.conf and /etc/wsl.conf as described above, and it took me a long while to figure out why GWSL was not working. Maybe use an if statement to apply the IP lookup method only if network.generateResolvConf = false, otherwise use the "cat /etc/resolv.conf " method?
The problem is that I don't think I know enough to be sure that this will be a sure way to know what GWSL should do. Especially since there are endless ways to change setting like this...