1

I connect my laptop to Pi through direct cable, so that I can share wifi connection with Pi .Like this:

enter image description here

I went to Control Panel-->Network and Internet-->Network connections, right click on Wifi ,select properties, and check on option "allow other network users......" on sharing section.My Pi can successfully connect to the Internet after this set-up.

But it is just a laptop, I have to unplug the cable from time to time, move the laptop, carry it back, and replug the cable.

Strange thing occurs now.Every time when I replug the cable, my Pi lost the Internet connection. I can still ssh to Pi from laptop, but I can't connect to the Internet from Pi.

pi@raspberry:~$ ping -c3 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.

--- 8.8.8.8 ping statistics ---
3 packets transmitted, 0 received, 100% packet loss, time 2042ms

pi@raspberry:~$ ping www.google.com
ping: www.google.com: Temporary failure in name resolution

I tried edit /etc/resolv.conf, still not working.

pi@raspberry:~$ cat /etc/resolv.conf
# Generated by resolvconf
nameserver 1.1.1.1
nameserver 8.8.8.8

After many tries, I simply turn off the "connection sharing option"from wifi properties ,and check on it again. Suddenly, Pi can successfully connect to the Internet! The problem just disappeared. enter image description here

How is this happening? What should I do to solve the problem once and for all? I dont want to turn off and on the checkbox everytime.

1
  • This is a problem with the laptop - nothing to do with Pi
    – Milliways
    Oct 11, 2022 at 6:55

1 Answer 1

1

ICS (Internet Connection Sharing) service in Windows has a timeout of 5 minutes or so. After that the ICS service is terminated and will not be restarted unless you manually click on the checkbox again.

ICS can be made persistent by setting

HKLM:\Software\Microsoft\Windows\CurrentVersion\SharedAccess\EnableRebootPersistConnection

parameter to 1 in the registry (create a new parameter of type dword if it doesn't exist), and changing the startup type of a service called SharedAccess to "Automatic" in

Control Panel -> Administrative Tools -> Services

or by running services.msc.

Perhaps it will help with short disconnects (not reboots) as well, but I didn't try it myself.

1
  • Thanks! It works immediately.
    – Smith John
    Oct 12, 2022 at 3:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.