Background
I was having problems with a python script on my MS Windows computer.
Chose to try out the same python script in Win OS / WSL Subsystem.
Python
Installed WLS, specifically Ubuntu flavored.
It comes with Python.
But, stuck trying to perform python module installs.
Network
Is it possible that the error is not Ubuntu Linux?
And, also the issue is not Python.
Introduction
Let us do a quick reconnaissance on the networking subsystem in Linux.
Networking Tools
Ping
Pinged a couple of sites such as google.com, cnn.com.
No good.
Ping Output
Text
Temporary failure in name resolution
Image
Troubleshooting
ip addr
In ubuntu, let us get our IP Address using “ip addr”.
Syntax
ip addr
Sample
ip addr | grep eth0
Output
Output-Image
Output-Text
6: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc mq state UP group default qlen 1000 inet 172.22.146.115/20 brd 172.22.159.255 scope global eth0
Explanation
- eth0
- Line 1
- State:- UP
- Line 2
- IP Address:- 172.22.146.115
- Gateway:- 172.22.159.255
- Line 1
Our ethernet (eth0) network interface is up.
We have a functional IP Address and Gateway.
ping
Attempted to ping cnn.com using it’s IP Address.
Go cnn.com IP Address using the MS Windows host.
BTW, CNN.COM’s is 151.101.1.67.
Resolution
Our issue appears to be name resolution.
Let us go clean up our resolv.conf configuration file.
resolv.conf
Outline
- Commented out current name server
- Change from:-
- nameserver 172.22.144.1
- Change to:-
- nameserver 172.22.144.1
- Change from:-
- Added new name servers
- In our case, roll pretty hard with Google
- nameserver 8.8.8.8
nameserver 8.8.4.4
- nameserver 8.8.8.8
- In our case, roll pretty hard with Google
Original
Image
Revised
Image
/etc/wsl.conf
Outline
- Inform wsl not to both generating the resolv.conf file
- It is a simple configuration entry
- vi /etc/wsl.conf
- Add
- [network]
- generateResolvConf = false
- Add
Revised
Image
Validation
ping
ping cnn.com
output
output image
Crediting
- Microsoft/WSL
- No network connection in any distribution under WSL 2 #5336
https://github.com/microsoft/WSL/issues/5336
Link - generateResolvConf = false did not work in wsl.conf #5611
https://github.com/microsoft/WSL/issues/5611
Link
- No network connection in any distribution under WSL 2 #5336
Summary
As of 2022-February-22nd, this continues to be an enduring and pernicious issue and stumbling block.
The change made to wls.conf does not hold.
One has to go back and re-add the following entries:-
[network]
generateResolvConf = false
ever so often.
I am not so sure whether it is WSL session-specific.
[…] WSL:- Networking Issue – Day 01 […]