4

I know there are other questions and even a Github issue about this, but I've tried all of the given answers and they don't work.

These are the contents of the relevant files:

  • /etc/hostname

    DESKTOP-42IRGSE
    
  • /etc/hosts

    127.0.0.1 localhost DESKTOP-42IRGSE
    # The following lines are desirable for IPv6 capable hosts
    ::1 ip6-localhost ip6-loopback
    fe00::0 ip6-localnet
    ff00::0 ip6-mcastprefix
    ff02::1 ip6-allnodes
    ff02::2 ip6-allrouters
    ff02::3 ip6-allhosts
    
  • /etc/resolv.conf

    #     DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    nameserver 195.130.131.1
    nameserver 195.130.130.1
    search home
    

DESKTOP-42IRGSE is indeed my computer's name, and the ips 195.130.131.1 and 195.130.130.1 match the DNS Servers in cmd's ipconfig /all.

Some debug command attempts:

root@DESKTOP-42IRGSE:~# ifconfig
Warning: cannot open /proc/net/dev (No such file or directory). Limited output.
root@DESKTOP-42IRGSE:~# ip link
SO_SNDBUF: Invalid argument
root@DESKTOP-42IRGSE:~# ping www.google.com
ping: unknown host www.google.com
root@DESKTOP-42IRGSE:~# ping 8.8.8.4        (or any other IP)
Do you want to ping broadcast? Then -b

Running apt-get update results in the same error as in the linked Github issue. I have disabled my firewall.

Todd Sewell
  • 149
  • 3
  • 10
  • Please edit your question and better describe what you mean by "can't connect to the internet", also include everything you've tried already, and what the results were. Can you ping Internet sites by IP address? Can you ping your DNS servers? How about your gateway? – Ƭᴇcʜιᴇ007 Aug 04 '16 at 15:48
  • @Ƭᴇcʜιᴇ007 When I ping my DNS servers or any other IP the ping command prints `Do you want to ping broadcast? Then -b` as the only output. DO you know what's up with that? – Todd Sewell Aug 04 '16 at 15:54
  • Looks like your problems are a [known biug](https://github.com/Microsoft/BashOnWindows/issues/239) – Ƭᴇcʜιᴇ007 Aug 04 '16 at 16:03
  • There they say ping etc. aren't working, but that apt-get should still work. It doesn't in my case, so I think I really have no network. – Todd Sewell Aug 04 '16 at 16:08

1 Answers1

3

You need to open an elevated command prompt first (run as admin) in order to ping successfully

Why does the ping command require bash to be started with admin privileges?

This is a known issue that has to due with differences between the way the Linux and the Windows kernel handle the ICMP request that makes ping possible. We plan to address this in future releases.

https://web.archive.org/web/20160914113514/https://msdn.microsoft.com/en-us/commandline/wsl/faq#why-does-the-ping-command-require-bash-to-be-started-with-admin-privileges

Update: "This issue was fixed in Build 14926 and later."


Another probable issue is that the firewall is messing up with your connection

Why do I not have internet access from WSL?

Some users have reported issues with specific firewall applications blocking internet access in WSL. The firewalls reported are:

  • Kaspersky
  • AVG
  • Avast

In some cases turning off the firewall allows for access. In some cases simply having the firewall installed looks to block access.

https://docs.microsoft.com/en-us/windows/wsl/faq#why-do-i-not-have-internet-access-from-wsl

phuclv
  • 26,555
  • 15
  • 113
  • 235
  • 1
    I opened cmd with Administrator privileges, ran the `bash` command and tried pinging... it still doesn't work. `apt-get` also still gives the same result. – Todd Sewell Aug 04 '16 at 16:44