POSTS / How to Get Host Machine's IP Address in WSL
i used to run this command to get hostip:
echo $(cat /etc/resolv.conf | grep -oP '(?<=nameserver ).*')
but today i found that the official guideline gives this command:
ip route show | grep -i default | awk '{print $3}'
However, these two methods can be different if disabling autoProxy in WSL-Config. Further check is needed.
Today I found that after I set autoProxy to false the second method gives the same ip address with which Clash for Windows gives, so I think maybe that’s the real trick for getting host machine’s ip address in WSL.