Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No internet access after reboot #3438

Closed
avxkim opened this issue Aug 4, 2018 · 68 comments
Closed

No internet access after reboot #3438

avxkim opened this issue Aug 4, 2018 · 68 comments
Labels

Comments

@avxkim
Copy link

avxkim commented Aug 4, 2018

OS Version: 10.0.16299 Build: 16299
Ubuntu 18.04 from microsoft store

After PC reboot i open Ubuntu from the start menu, and trying to ping google.kz (using bash), getting an error:

ping: google.kz: Temporary failure in name resolution

Then i check:

cat /etc/resolv.conf

File not found. Not using any VPN, just windows defender and malwarebytes (i've tried to turn it off, but no result). I guess WSL is having trouble launching some auto scripts to create resolv.conf?

@Biswa96
Copy link

Biswa96 commented Aug 4, 2018

Try to add DNS server IP address with: echo 8.8.8.8 > /etc/resolv.conf.

@avxkim
Copy link
Author

avxkim commented Aug 4, 2018

sudo echo 8.8.8.8 > /etc/resolv.conf

Output:

bash: /etc/resolv.conf: Permission denied

Even with sudo i can't

@onomatopellan
Copy link

onomatopellan commented Aug 4, 2018

@heihachi88 What's the output of ll /etc/resolv.conf and ll /run/resolvconf/resolv.conf ?

@avxkim
Copy link
Author

avxkim commented Aug 4, 2018

both files empty... what the hell, yesterday it worked after reboot, approx after 1 hour. Nothing new i installed.

@onomatopellan
Copy link

onomatopellan commented Aug 4, 2018

Empty or file did not exist? I was interested in the file permissions. This is what it looks like:.

onoma@DESKTOP:~$ ll /etc/resolv.conf
lrwxrwxrwx 1 root root 29 May 11 21:15 /etc/resolv.conf -> ../run/resolvconf/resolv.conf
onoma@DESKTOP:~$ ll /run/resolvconf/resolv.conf
-rw-r--r-- 1 root root 147 Aug  4 20:28 /run/resolvconf/resolv.conf

Seems file got corrupted or something. I would uninstall the Ubuntu18.04 app and reinstall it to see if it happens again.

@avxkim
Copy link
Author

avxkim commented Aug 4, 2018

Files didn't exist.

Are you sure it's not 18.04 issue? Are you using 18.04 yourself?

@onomatopellan
Copy link

Yes, I'm using 18.04 but I'm using build 17134. Can't you upgrade your Windows 10?

@avxkim
Copy link
Author

avxkim commented Aug 4, 2018

How can i upgrade build? I must switch to beta or something? I just migrated from MacOS (used it last 6 years)

@onomatopellan
Copy link

onomatopellan commented Aug 4, 2018

If it's your computer this should work
https://support.microsoft.com/en-us/help/4027667/windows-update-windows-10

If it doesn't appear on Windows Update you can also use the Updater Assistant or create a installation media:
https://www.microsoft.com/en-us/software-download/windows10

@avxkim
Copy link
Author

avxkim commented Aug 5, 2018

Updated to 1803, same picture. After sleep / reboot, no resolv.conf, i even reinstalled Ubuntu 18.04

How to manually run that resolv script in WSL?

@avxkim
Copy link
Author

avxkim commented Aug 5, 2018

Ended it this way:

sudo bash -c 'echo "nameserver 8.8.8.8" > /etc/resolv.conf'
sudo bash -c 'echo "nameserver 8.8.4.4" >> /etc/resolv.conf'

exit

-c parameter was missing from @Biswa96 answer, now my DNS is working, but still, why DOES it happening?

@MVoz
Copy link

MVoz commented Aug 5, 2018

You have problems with the network adapter, WSL is not at all .WSL uses WinSocket

@avxkim
Copy link
Author

avxkim commented Aug 5, 2018

@voskrese if i had a problem with the network adapter, then in windows i would have the same problem, but on Windows i have no issues related to DNS.

@Biswa96
Copy link

Biswa96 commented Aug 5, 2018

@heihachi88 No, I missed the nameserver word. BTW, the resolv.conf file should be automatically created. And it's a symbolic link to /run/resolvconf/resolv.conf. Try to delete that /etc/resolv.conf and exit from wsl.exe. Then rerun wsl.exe and check if that file/symbolic link will automatically created or not.

@avxkim
Copy link
Author

avxkim commented Aug 5, 2018

@Biswa96 I can't delete not existing file, both files you mentioned didn't exist, before i manually injected them and exit shell, then relaunch again.

@MVoz
Copy link

MVoz commented Aug 5, 2018

2018-08-05_205123

возможно поможет сброс


netsh winsock reset
netsh int ip reset all
netsh winhttp reset proxy
ipconfig /flushdns

reboot

@JoBrad
Copy link

JoBrad commented Aug 6, 2018

@voskrese your instructions helped me - thanks!

Weird that this became a problem after upgrading to build 17730. I had no issues with DNS prior to upgrading, and pinging via IP worked fine.

@avxkim
Copy link
Author

avxkim commented Aug 6, 2018

@voskrese is reboot necessary? I'll try it next time it won't resolve.

@MVoz
Copy link

MVoz commented Aug 6, 2018

@heihachi88 This is a recommendation, once reboot to have entered new settings, I think is not the same and the problem

@avxkim
Copy link
Author

avxkim commented Aug 7, 2018

@voskrese tried your changes, even rebooted 🤣 , but still no /etc/resolv.conf just WTF is this.

@onomatopellan
Copy link

Try to recover resolv.conf again (uninstalling the app and reinstalling?) and just after waking up PC from sleep get some logs following this:
https://github.com/Microsoft/WSL/blob/master/CONTRIBUTING.md#8-detailed-logs

@avxkim
Copy link
Author

avxkim commented Aug 7, 2018

I've already reinstalled Ubuntu 18.04 twice, maybe it's hardware? Can i just hardcode this /etc/resolv.conf, so it won't regenerate by WSL all the time.

When last time i had correct DNS in WSL, it had following entries:

# This file was automatically generated by WSL. To stop automatic generation of this file, remove this line.

nameserver 10.0.1.1
nameserver fec0:0:0:ffff::1
nameserver fec0:0:0:ffff::2

@onomatopellan
Copy link

onomatopellan commented Aug 7, 2018

Please post the logs. It could be your internet configuration or some permission problem.
The process would be:

  1. close bash window
  2. sleep PC and wake up PC
  3. start logs
  4. open bash
  5. stop logs
  6. post logs here

@MVoz
Copy link

MVoz commented Aug 7, 2018

@heihachi88
I did not write that I will create a file resolv. conf, I said that you have problems with the drivers and the network in Windows
Essentially resolv. conf is under the configuration as well as the host file

What service uses resolv. conf in WSL? No, only utilities working with the network, by custom

@MVoz
Copy link

MVoz commented Aug 7, 2018

@heihachi88 Well, if you want to deal with the network in more detail, here everything is described
https://wiki.debian.org/NetworkConfiguration

In the most complex situations, using resolvconf really is the way to go, though in more simple configurations it is probably overkill.

apt-get install resolvconf

Check network card settings

cat /etc/network/interfaces

Add DNS to the Resolvconf utility

added

nameserver 8.8.8.8
nameserver 8.8.4.4

to

/etc/resolvconf/resolv.conf.d/base
/etc/resolvconf/resolv.conf.d/tail

sudo resolvconf -u

@MVoz
Copy link

MVoz commented Aug 7, 2018

Alternatively, firewall may block outbound connection

WINDOWS

cmd.exe

netsh advfirewall set allprofiles state off

WSL

bash.exe

ping google.com

ON firewall

netsh advfirewall set allprofiles state on

Сбросить конфигурацию брандмауэра к установкам по умолчанию:

netsh advfirewall reset

@avxkim
Copy link
Author

avxkim commented Aug 7, 2018

Windows defender you mean?

@MVoz
Copy link

MVoz commented Aug 7, 2018

I traced the process that is responsible for going into the WSL network, apparently as a layer

https://github.com/henrypp/simplewall

под названием PICO

2018-08-07_184148

@wonkyroger
Copy link

  1. Run wsl.exe
  2. Open C:\Users\%USERNAME%\AppData\Local\lxss\rootfs\etc\resolv.conf
    It should looks like ../run/resolvconf/resolv.conf
  3. Replace all with line nameserver 8.8.8.8
  4. Save
  5. Execute cat /etc/resolv.conf to check changes
    It should looks like nameserver 8.8.8.8

After these steps my problem was fixed.
I hope it helps you too.

@pauloscardine
Copy link

pauloscardine commented Jul 31, 2019

Looks like there is some problem with WSL networking on build 18945. After booting, the WSL virtual interface got the following address:

$ ifconfig eth0
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.170.29  netmask 255.255.255.0  broadcast 192.168.170.255
        inet6 fe80::215:5dff:fe70:91d2  prefixlen 64  scopeid 0x20<link>
        ether 00:15:5d:70:91:d2  txqueuelen 1000  (Ethernet)
        RX packets 1892  bytes 285656 (285.6 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 21  bytes 1586 (1.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

On the windows side, the WSL interface was:

PS C:\Users\paulos> ipconfig
...
Ethernet adapter vEthernet (WSL):

  Connection-specific DNS Suffix  . :
  Link-local-IPv6 Address . . . . . : fe80::a07a:25bd:e562:a887%61
  IPv4 Address. . . . . . . . . . . : 192.168.160.1
  Subnet Mask . . . . . . . . . . . : 255.255.240.0
  Default Gateway . . . . . . . . . :
...

I think the problem is that the default gateway on the linux side should be 192.168.160.1 but since it is outside the 192.168.170.0/24 network the WSL instance ends up without a default gateway.

If I change the netmask to 255.255.240.0 and add the windows IP as default gateway on the linux side too, voila! problem fixed:

$ sudo ifconfig eth0 192.168.170.29 netmask 255.255.240.0
$ sudo route add default gw 192.168.160.1

I guess that after the upgrade the netmask on the Windows side changed and the virtual DHCP server is providing the wrong one for the WSL host (may be it was hardcoded). Or vice-versa. Anyway the workaround is:

  1. check the netmask on the windows side using ipconfig (look for the WSL interface)
  2. if the windows netmask has less bits than the linux netmask change the netmask on the linux side
  3. add a default route pointing to the IP of the windows network interface.

Windows side (ipconfig):
image

Linux side:
image

@AhtiAhde
Copy link

AhtiAhde commented Sep 21, 2020

For some of us this seems to be a Windows Defender / Security related issue.

What happens is, that if you upgrade your machine or for some other reason Windows Security reboots with warning, it will disconnect WSL 2. This is good and expected behavior.

The symptom should be that when you ping google.com, it should fail (for me it just freezes and when I ctrl-C, I get that all packages have been lost).

Then you should fix the warnings (usually this means re-enabling "Reptutation-based protection" under the "App & browser control" as that seems to be turned off upon every update for Windows 10), and do the following:

  1. Disable firewall temporarily by running this in PowerShell: netsh advfirewall set allprofiles state off
  2. Go to WSL 2 and retry ping google.com, this should now work, if the problem was related to Windows Security and warnings (it can also relate to firewalls and VPN; you have to google for solving those)
  3. Re-enable firewall by running this in PowerShell: netsh advfirewall set allprofiles state on
  4. The reset the firewall and you should be fine: netsh advfirewall reset

This worked nicely for me.

EDIT: I also needed to do this: echo "nameserver 8.8.8.8" | sudo tee /etc/resolv.conf; trying to figure out a nice way to persist this.

EDIT 2: Actually I didn't need to do that /etc/resolv.conf fix. It seems that whenever your network configuration changes, then after you have signed in with different user or let the machine sleep for long enough, the Hyper V will get confused with the network adapters. Reboot should be the primary solution model. Only apply these other solutions after you have tried rebooting as they can potentially break up the way your system is supposed to work and will cause long term chain of problems until you end up in situation of reinstalling your distribution. There seems to be some problem with the dynamics between Hyper V, network adapters and WSL 2 that only surfaces with a delay, probably caused by event of "sleep". This problem seems so complex, because all changes in the network settings seem to potentially trigger it (firewall, VPN, system updates, Docker updates...).

@lukee1234
Copy link

If you modified, moved or compressed the temp folder, look at #5437 for the solution

@krehwell
Copy link

source: stackoverflow
based on the above, it resolves my problem.

Open windows cmd in admin mode and type thses commands

1. netsh winsock reset
2. netsh int ip reset all
3. netsh winhttp reset proxy
4. ipconfig /flushdns
5. reboot

@MaxPowerWasTaken
Copy link

Someone recommended this to me for alleviating a (different but probably related) wsl2 internet connectivity issue:
https://github.com/sakai135/wsl-vpnkit

@gustavo-lara-molina
Copy link

I fix this with windows 11:
#5336 (comment)

@emma3kevin
Copy link

This is what helped to me ... I am having WSL2 and using VPN (Cisco Anyconnect) to connect to my company network.

WSL2 VM is configured with INTERNAL type of connection of virtual switch be default, which can be the main reason for issues, so we could think about to change to EXTERNAL.

image

  1. update the resolv.conf with 8.8.8.8 (ensure that it is not being overwritten after reboot, see elsewhere how to do it )

  2. In powershell with admin privs: Get-NetAdapter | Where-Object {$_.InterfaceDescription -Match "Cisco AnyConnect"} | Set-NetIPInterface -InterfaceMetric 4000

  3. Optionally: Get-NetIPInterface -InterfaceAlias "vEthernet (WSL)" | Set-NetIPInterface -InterfaceMetric 1

Not sure what this exactly does, and how to do it other way and permanently, but it works.

@ivanvallenas
Copy link

If you can ping web pages from the linux terminal you can try turning off all your firewalls or antivirus. It worked for me.

@karthik-baba
Copy link

I was able to solve this issue with the following steps

  1. Open Powershell in admin mode
  2. Enter wsl
  3. in my case i was not able to edit, resolve.conf -- so i had to do rm /etc/resolve.conf
  4. vi /etc/resolve.conf (create anyway)
  5. add the following line : nameserver 8.8.8.8
  6. Save it
  7. Restart the PC
  8. it worked

@YevheniiPokhvalii
Copy link

This bug happened to me after installing VirtualBox 6.1.34 - WSL network stopped working.
In order to be able to use VPN beside my home network (the trick with 8.8.8.8 did not work here), I added my router gateway IP as a nameserver to the WSL config:

> netsh interface ip show config "WiFi"

Configuration for interface "WiFi"
    DHCP enabled:                         Yes
    IP Address:                           192.168.0.106
    Subnet Prefix:                        192.168.0.0/24 (mask 255.255.255.0)
    Default Gateway:                      192.168.0.1
    Gateway Metric:                       0
    InterfaceMetric:                      50
    DNS servers configured through DHCP:  192.168.0.1
    Register with which suffix:           Primary only
    WINS servers configured through DHCP: None

Check if you can ping the router gateway in WSL:

$ ping -c1 192.168.0.1
PING 192.168.0.1 (192.168.0.1) 56(84) bytes of data.
64 bytes from 192.168.0.1: icmp_seq=1 ttl=63 time=2.49 ms

--- 192.168.0.1 ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 2.487/2.487/2.487/0.000 ms

(optionally) Check the content of /etc/resolv.conf. You will see a description there:

$ cat /etc/resolv.conf
# This file was automatically generated by WSL. To stop automatic generation of this file, add the following entry to /etc/wsl.conf:
# [network]
# generateResolvConf = false
nameserver 172.24.208.1

Create /etc/wsl.conf in WSL:

$ cat /etc/wsl.conf
[network]
generateResolvConf = false

In Powershell:

wsl --shutdown

In WSL:

sudo bash -c 'echo "nameserver 192.168.0.1" > /etc/resolv.conf'

Works even after the system reboot, no chattr is required.

However, the reason why this issue happened is still unclear.

@VarunBanka
Copy link

OS Version: 10.0.16299 Build: 16299 Ubuntu 18.04 from microsoft store

After PC reboot i open Ubuntu from the start menu, and trying to ping google.kz (using bash), getting an error:

ping: google.kz: Temporary failure in name resolution

Then i check:

cat /etc/resolv.conf

File not found. Not using any VPN, just windows defender and malwarebytes (i've tried to turn it off, but no result). I guess WSL is having trouble launching some auto scripts to create resolv.conf?

i was also having same issue, here's how i have fixed
open windows PowerShell as admin and type the following

netsh advfirewall set allprofiles state off

then press enter
restart
hope it helps

1 similar comment
@VarunBanka
Copy link

OS Version: 10.0.16299 Build: 16299 Ubuntu 18.04 from microsoft store

After PC reboot i open Ubuntu from the start menu, and trying to ping google.kz (using bash), getting an error:

ping: google.kz: Temporary failure in name resolution

Then i check:

cat /etc/resolv.conf

File not found. Not using any VPN, just windows defender and malwarebytes (i've tried to turn it off, but no result). I guess WSL is having trouble launching some auto scripts to create resolv.conf?

i was also having same issue, here's how i have fixed
open windows PowerShell as admin and type the following

netsh advfirewall set allprofiles state off

then press enter
restart
hope it helps

@jikuja
Copy link

jikuja commented Jul 13, 2022

OS Version: 10.0.16299 Build: 16299 Ubuntu 18.04 from microsoft store
After PC reboot i open Ubuntu from the start menu, and trying to ping google.kz (using bash), getting an error:

ping: google.kz: Temporary failure in name resolution

Then i check:

cat /etc/resolv.conf

File not found. Not using any VPN, just windows defender and malwarebytes (i've tried to turn it off, but no result). I guess WSL is having trouble launching some auto scripts to create resolv.conf?

i was also having same issue, here's how i have fixed open windows PowerShell as admin and type the following

netsh advfirewall set allprofiles state off

then press enter restart hope it helps

What are the security risks of doing that?

@jjcf89
Copy link

jjcf89 commented Jul 14, 2022

What are the security risks of doing that?

Looks like it's disabling your windows firewall. Wouldn't recommend

@VarunBanka
Copy link

OS Version: 10.0.16299 Build: 16299 Ubuntu 18.04 from microsoft store
After PC reboot i open Ubuntu from the start menu, and trying to ping google.kz (using bash), getting an error:

ping: google.kz: Temporary failure in name resolution

Then i check:

cat /etc/resolv.conf

File not found. Not using any VPN, just windows defender and malwarebytes (i've tried to turn it off, but no result). I guess WSL is having trouble launching some auto scripts to create resolv.conf?

i was also having same issue, here's how i have fixed open windows PowerShell as admin and type the following
netsh advfirewall set allprofiles state off
then press enter restart hope it helps

What are the security risks of doing that?

He shouldn't disable firewall. Instead he should use linux in vm

@VarunBanka
Copy link

OS Version: 10.0.16299 Build: 16299 Ubuntu 18.04 from microsoft store
After PC reboot i open Ubuntu from the start menu, and trying to ping google.kz (using bash), getting an error:

ping: google.kz: Temporary failure in name resolution

Then i check:

cat /etc/resolv.conf

File not found. Not using any VPN, just windows defender and malwarebytes (i've tried to turn it off, but no result). I guess WSL is having trouble launching some auto scripts to create resolv.conf?

i was also having same issue, here's how i have fixed open windows PowerShell as admin and type the following
netsh advfirewall set allprofiles state off
then press enter restart hope it helps

What are the security risks of doing that?

There are major security ricks of doing that so it's not recommended but what I would recommend is using using linux on vm. Fell free to contact me for any errors or anything.....

@bayangan
Copy link

I changed nameserver in /etc/resolv.conf using IP i found from public dns, replacing the usual google dns 8.8.8.8 or 1.1.1.1

No need to restart wsl or computer.
To test the connection can simply run
$ composer diagnose
or
$ sudo apt update
or
ping reknown domain
$ ping google.com

Note: I notice this problem happens sometimes after restarting computer due to windows update (cross finger)

@YevheniiPokhvalii
Copy link

YevheniiPokhvalii commented Nov 11, 2022

@bayangan

You may still have issues after that so use your Default Gateway (by default 192.168.0.1) in /etc/resolv.conf instead of Google public DNS or any other public DNS.

@VarunBanka
Copy link

@bayangan

You may still have issues after that so use your Default Gateway (by default 192.168.0.1) in /etc/resolv.conf instead of Google public DNS or any other public DNS.

I've tried it but it needs to be changed after every restart, however I was able to fix it by:

opening the windows PowerShell as admin and typing the following

netsh advfirewall set allprofiles state off

then pressing enter
restarting

But there are major security ricks of doing that so it's not recommended but what I would recommend is using using linux on vm instead.....

@CaretakerBlayze
Copy link

Nothing helped. I deleted wsl and now i can't even open google. I just don't have internet connection. Please help

@bernardosts
Copy link

bernardosts commented Aug 25, 2023

Still with the same issue. Somehow the network between the host and the WSL VM is broken after some actions. With me happens always when I need to connect to any VPN. Just after vpn connection everything works fine. When I disconnect from the vpn wsl vm can't access the internet anymore. I have tried all those commands to restart the windows network stack, wsl vm reboot, restart the wsl system service. Nothing works at all, except a windows reboot. This is really annoying. I hope that you guys figure this out in the near future. I would hate to miss the integrated experience of using WSL (and turn to an VM) because of this...

@craigloewen-msft
Copy link
Member

Hi folks, we have put out a new update that aims to address networking issues in WSL. In your .wslconfig file you can set experimental.networkingMode=mirrored, as well as some other key settings that should improve your network compatibility, and add support for IPv6! Please try them out and let us know what you think.

More info on this release and the changes can be found here in the blog post.

Please note: You need to be on a Windows Insiders version to use the new networking settings (Any channel of Windows Insiders will do, including release preview). If you see the "These are not supported" messages it means that your current Windows version doesn't have support, and you will need to upgrade. These features will eventually be coming to Windows 11 22H2.

Please see megathread for DNS issues in WSL: #8365

@OneBlue
Copy link
Collaborator

OneBlue commented May 14, 2024

Hi ! Please try the latest networking features that we've added in WSL. Those should greatly improve compatibility with VPN's.

If the issue still remains, please reopen this issue.

@OneBlue OneBlue closed this as completed May 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests