Closed GoodbyeNJN closed 4 years ago
Thanks for the PR.
Curious if we can come up with a solution that works on any distro. If we only rely on the kernel we should be able to find a solution.
Mind running this in Arch or any other distro to see if it works?
awk '/32 host LOCAL/ { if (f != "127.0.0.1") { print f; exit } } {f=$2}' /proc/net/fib_trie
We wouldn't rely on awk
but for the sake of checking, the above command should print out the WSL VM IP.
Thanks for your reply. This command works fine in Arch. Need more test in any other distro.
Pushed release v0.3.3 which uses the fib_trie approach to get IP address in a distro agnostic way. https://github.com/shayne/go-wsl2-host/releases/tag/v0.3.3
Command
hostname -I
is not available to get VM's IP address in some cases, e.g in Arch Linux, so I did something to let user set custom command. For the reason that~/.wsl2hosts
was already used to set custom host alias, I combined these. Now we can set custom command and custom host alias in one file.