Rick Strahl's Weblog  

Wind, waves, code and everything in between...
.NET • C# • Markdown • WPF • All Things Web
Contact   •   Articles   •   Products   •   Support   •   Advertise
Sponsored by:
West Wind WebSurge - Rest Client and Http Load Testing for Windows

Windows 10 Bash Shell Network Connectivity not working?


:P
On this page:

I started playing around with the Windows 10 Anniversary edition Bash shell in build 14316, and one of the first problems I ran into was that network connectivity wasn't working. Any network command – curl, apt-get etc. just hangs.

IPv6 DNS Addresses not Working

When you install the Ubuntu subsystem (from Windows Features), the system settings from Windows are copied into the resolve.conf file, so it inherits the current Windows settings, which should be fine since that clearly works in Windows. But alas, in the Ubuntu Bash shell  I get no connectivity.

It appears the problem is that the Ubuntu subsystem doesn't deal properly with IPv6 IP Addresses that are listed by default in the network resolution file. The IPv6 addresses are first in the list and apparently that doesn't work. The simple fix, is to swap the the IPv4 and IPv6 addresses and – voila, network access works.

This is likely a temporary problem but definitely an issue in the current 15316 build of Windows 10 IP that I'm running.

Edit your resolv.config

To fix you can bring up an editor like this:

nano /etc/resolv.conf

My original file looked like this:
ResolveConfigOrigBash

Notice the IPv6 address at the top of the nameservers list.

Moving the IPv6 servers below (Ctrl-K to copy Ctrl-U to paste single line):

ResolveConfigOrigBash2

Save with Ctrl-O, and you're off to the races – Internet Connectivity is back. curl and apt-get, which is what I needed to use earlier, now works.

Accessing the File System from Windows

If editing text through a screen based editor feels a bit quaint as it does to me, you can also access the Linux file system from Windows and Explorer so you can use your favorite editor to interact with the file system.

The location of the subsystem is at:

C:\Users\<username>\AppData\Local\lxss\rootfs

From there you can dig directly into the file system and look at files.

FilesystemEdit

You can easily edit files from the Linux file system. Keep in mind that standard Unix file forwarding and links aren't going to work when you use the Windows shell for editing. In the file edit above the forward didn't work automatically and I had to follow the link to open the file on the right.

 

Other Network Problems

There are a still some things that don't work.

I still can't run ifconfig which gives me:

root@localhost:~# ifconfig
Warning: cannot open /proc/net/dev (No such file or directory). Limited output.

Not sure what's causing this and searching around for this doesn't bring up anything useful other than installation errors for a distro (not specific to this Windows shell).

Likewise some commands continue to not work. ping also fails:

root@localhost:~# ping west-wind.com
ping: icmp open socket: Socket type not supported

There's a long thread on a GitHub issue around all of these problems with no resolution yet with the exception of the main connectivity issue. But I suspect these are just early version blues – this stuff will get sorted out. For the moment, I have enough connectivity to get stuff done.

Posted in Windows  Linux  

The Voices of Reason


 

Mark
April 14, 2016

# re: Windows 10 Bash Shell Network Connectivity not working?

Thanks for posting this. I had a different variation of the same problem. I was connected to a VPN when I installed, so my first DNS server was on a network that I was not always connected to.

Mark
April 23, 2016

# re: Windows 10 Bash Shell Network Connectivity not working?

Everything you mentioned as broken in 14316 is still broke in 14328. Thanks for the resolv.conf tip, it didn't even exist in my installation I had to create it.

Rick Strahl
April 23, 2016

# re: Windows 10 Bash Shell Network Connectivity not working?

@Mark - yup found that out as well and got a note from one of the program managers that this has been addressed but the fixes didn't make it into the 14328 build. Hopefully this stuff will show up in the next drops or maintenenace releases.

Alex
April 26, 2016

# re: Windows 10 Bash Shell Network Connectivity not working?

Thank you, my resolv.conf was empty but just adding a 'nameserver 8.8.8.8' line did the trick.

Ben
August 03, 2016

# re: Windows 10 Bash Shell Network Connectivity not working?

Hello,

About the ping command and this message :

root@localhost:~# ping west-wind.com
ping: icmp open socket: Socket type not supported

I had this :

root@MY-PC:~$ ping google.fr
ping: icmp open socket: Permission denied

I solved this problem by starting the shell application as administrator. I think that this shell and the root one do not and/or can not have the full power on the computer.

Dave
August 11, 2016

# re: Windows 10 Bash Shell Network Connectivity not working?

I am not surprised by the permission issue when attempting to ping. I had the same thing happen with Cygwin and for the same reason. As Ben indicated, the solution is to run the shell as administrator.

LoloBary
February 26, 2017

# re: Windows 10 Bash Shell Network Connectivity not working?

Just perform Bash installation with Administrator privileges ("Run as Administrator")


Mizumaky
November 07, 2018

# re: Windows 10 Bash Shell Network Connectivity not working?

Tried many methods which didnt work when finally TURNING OFF my Kaspersky Free ANTIVIRUS helped me with the network problems. (by turning off i dont mean just pausing protection)


Jason
April 04, 2019

# re: Windows 10 Bash Shell Network Connectivity not working?

Running as admin from windows works, you can also just try running sudo ping xxx.xxx.xxx.xxx, most of the connectivity issues I had were resolved that way.


West Wind  © Rick Strahl, West Wind Technologies, 2005 - 2024