2

My raspberry pi 3 is configured to connect to my WiFi using an external usb wifi dongle.

It actually connets to it most of the time. But, at some point, the connection drops, it reconnects to the wireless network but cannot get an IP from DHCP. A few points:

  • interesting logs at the end of this post
  • the router is cheap and dumb, can't have any log from it (a locked Technicolor from my ISP)
  • dhcp is running on the router, where a rule for assigning the address 192.168.1.6 is set for the rpi wifi mac address
  • the problem happens only after sometime, never at boot
  • wifi signal is poor so I expect a few reconnection a day can be necessary
  • iwconfig reports wlan0 as connected
  • no errors reported in log
  • even if I switch to static ip, the rpi is not actually connected (cannot ping anything..)
  • if I do "ifconfig wlan0 down && ifconfig wlan0 up" I get the correct ip almost immediately
  • if I turn off & on the router wifi, the rpi reconnects almost immediately

This is my current configuration:

/etc/network/interfaces

allow-hotplug wlan0
iface wlan0 inet manual
    wpa-conf /etc/wpa_supplicant/wpa_supplicant.conf

/etc/dhcpcd.conf

hostname
clientid
persistent
option rapid_commit
option domain_name_servers, domain_name, domain_search, host_name
option classless_static_routes
option ntp_servers
option interface_mtu
require dhcp_server_identifier
slaac private

ifconfig wlan0

wlan0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.1.6  netmask 255.255.255.0  broadcast 192.168.1.255
        inet6 fe80::ec34:fad0:796d:7d27  prefixlen 64  scopeid 0x20<link>
        ether e8:4e:06:10:32:88  txqueuelen 1000  (Ethernet)
        RX packets 680232  bytes 198700140 (189.4 MiB)
        RX errors 0  dropped 19  overruns 0  frame 0
        TX packets 841682  bytes 668940432 (637.9 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

iwconfig wlan0

wlan0     IEEE 802.11  ESSID:"tartumaa"  
          Mode:Managed  Frequency:2.412 GHz  Access Point: 10:13:31:CA:19:6D   
          Bit Rate=65 Mb/s   Tx-Power=20 dBm   
          Retry short limit:7   RTS thr=2347 B   Fragment thr:off
          Encryption key:off
          Power Management:off
          Link Quality=37/70  Signal level=-73 dBm  
          Rx invalid nwid:0  Rx invalid crypt:0  Rx invalid frag:0
          Tx excessive retries:0  Invalid misc:1434   Missed beacon:0

Log when the error occurs:

apr 19 16:12:38 rpicasina dhcpcd[3974]: wlan0: carrier lost
apr 19 16:12:38 rpicasina dhcpcd[3974]: wlan0: carrier lost
apr 19 16:12:38 rpicasina kernel: rtlwifi: AP off, try to reconnect now
apr 19 16:12:38 rpicasina kernel: rtlwifi: AP off, try to reconnect now
apr 19 16:12:38 rpicasina kernel: wlan0: Connection to AP 10:13:31:ca:19:6d lost
apr 19 16:12:38 rpicasina kernel: rtlwifi: AP off, try to reconnect now
apr 19 16:12:38 rpicasina kernel: wlan0: Connection to AP 10:13:31:ca:19:6d lost
apr 19 16:12:39 rpicasina dhcpcd[3974]: wlan0: deleting address fe80::ec34:fad0:796d:7d27
apr 19 16:12:39 rpicasina avahi-daemon[323]: Withdrawing address record for fe80::ec34:fad0:796d:7d27 on wlan0.
apr 19 16:12:39 rpicasina avahi-daemon[323]: Leaving mDNS multicast group on interface wlan0.IPv6 with address fe80::ec34:fad0:796d:7d27.
apr 19 16:12:39 rpicasina avahi-daemon[323]: Interface wlan0.IPv6 no longer relevant for mDNS.
apr 19 16:12:39 rpicasina dhcpcd[3974]: wlan0: deleting default route via 192.168.1.1
apr 19 16:12:39 rpicasina dhcpcd[3974]: wlan0: deleting route to 192.168.1.0/24
apr 19 16:12:39 rpicasina avahi-daemon[323]: Withdrawing address record for 192.168.1.6 on wlan0.
apr 19 16:12:39 rpicasina avahi-daemon[323]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 192.168.1.6.
apr 19 16:12:39 rpicasina avahi-daemon[323]: Interface wlan0.IPv4 no longer relevant for mDNS.
apr 19 16:12:40 rpicasina kernel: wlan0: authenticate with 10:13:31:ca:19:6d
apr 19 16:12:40 rpicasina kernel: wlan0: send auth to 10:13:31:ca:19:6d (try 1/3)
apr 19 16:12:40 rpicasina kernel: wlan0: authenticated
apr 19 16:12:40 rpicasina kernel: wlan0: associate with 10:13:31:ca:19:6d (try 1/3)
apr 19 16:12:40 rpicasina kernel: wlan0: RX AssocResp from 10:13:31:ca:19:6d (capab=0x1011 status=0 aid=1)
apr 19 16:12:40 rpicasina kernel: wlan0: associated
apr 19 16:12:41 rpicasina dhcpcd[3974]: wlan0: carrier acquired
apr 19 16:12:41 rpicasina dhcpcd[3974]: wlan0: IAID 06:10:32:88
apr 19 16:12:41 rpicasina dhcpcd[3974]: wlan0: adding address fe80::ec34:fad0:796d:7d27
apr 19 16:12:41 rpicasina avahi-daemon[323]: Joining mDNS multicast group on interface wlan0.IPv6 with address fe80::ec34:fad0:796d:7d27.
apr 19 16:12:41 rpicasina avahi-daemon[323]: New relevant interface wlan0.IPv6 for mDNS.
apr 19 16:12:41 rpicasina avahi-daemon[323]: Registering new address record for fe80::ec34:fad0:796d:7d27 on wlan0.*.
apr 19 16:12:42 rpicasina dhcpcd[3974]: wlan0: rebinding lease of 192.168.1.6
apr 19 16:12:42 rpicasina dhcpcd[3974]: wlan0: soliciting an IPv6 router
apr 19 16:12:47 rpicasina dhcpcd[3974]: wlan0: probing for an IPv4LL address
apr 19 16:12:47 rpicasina dhcpcd[3974]: wlan0: DHCP lease expired
apr 19 16:12:47 rpicasina dhcpcd[3974]: wlan0: soliciting a DHCP lease
apr 19 16:12:52 rpicasina dhcpcd[3974]: wlan0: using IPv4LL address 169.254.118.239
apr 19 16:12:52 rpicasina avahi-daemon[323]: Joining mDNS multicast group on interface wlan0.IPv4 with address 169.254.118.239.
apr 19 16:12:52 rpicasina avahi-daemon[323]: New relevant interface wlan0.IPv4 for mDNS.
apr 19 16:12:52 rpicasina avahi-daemon[323]: Registering new address record for 169.254.118.239 on wlan0.IPv4.
apr 19 16:12:52 rpicasina dhcpcd[3974]: wlan0: adding route to 169.254.0.0/16
apr 19 16:12:52 rpicasina dhcpcd[3974]: wlan0: adding default route

As you can see, it ask for an address but after 5 seconds use the "fallback" 169. It makes sense, as I am pretty much convinced the rpi is not really connected. As I stated above, even if I use the static ip, at this point a I can't ping anything else.

These are the logs when everythings is ok:

apr 19 16:55:41 rpicasina kernel: wlan0: deauthenticating from 10:13:31:ca:19:6d by local choice (Reason: 3=DEAUTH_LEAVING)
apr 19 16:55:41 rpicasina dhcpcd[3974]: wlan0: carrier lost
apr 19 16:55:41 rpicasina avahi-daemon[323]: Interface wlan0.IPv6 no longer relevant for mDNS.
apr 19 16:55:41 rpicasina avahi-daemon[323]: Leaving mDNS multicast group on interface wlan0.IPv6 with address fe80::ec34:fad0:796d:7d27.
apr 19 16:55:41 rpicasina avahi-daemon[323]: Interface wlan0.IPv4 no longer relevant for mDNS.
apr 19 16:55:41 rpicasina avahi-daemon[323]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 169.254.118.239.
apr 19 16:55:41 rpicasina avahi-daemon[323]: Withdrawing address record for fe80::ec34:fad0:796d:7d27 on wlan0.
apr 19 16:55:41 rpicasina avahi-daemon[323]: Withdrawing address record for 169.254.118.239 on wlan0.
apr 19 16:55:41 rpicasina kernel: rtl8192cu: MAC auto ON okay!
apr 19 16:55:41 rpicasina dhcpcd[3974]: wlan0: deleting address fe80::ec34:fad0:796d:7d27
apr 19 16:55:41 rpicasina kernel: rtl8192cu: Tx queue select: 0x05
apr 19 16:55:43 rpicasina avahi-daemon[323]: Joining mDNS multicast group on interface wlan0.IPv4 with address 169.254.118.239.
apr 19 16:55:43 rpicasina avahi-daemon[323]: New relevant interface wlan0.IPv4 for mDNS.
apr 19 16:55:43 rpicasina kernel: IPv6: ADDRCONF(NETDEV_UP): wlan0: link is not ready
apr 19 16:55:43 rpicasina avahi-daemon[323]: Registering new address record for 169.254.118.239 on wlan0.IPv4.
apr 19 16:55:43 rpicasina avahi-daemon[323]: Withdrawing address record for 169.254.118.239 on wlan0.
apr 19 16:55:43 rpicasina dhcpcd[3974]: wlan0: deleting default route
apr 19 16:55:43 rpicasina dhcpcd[3974]: wlan0: deleting route to 169.254.0.0/16
apr 19 16:55:43 rpicasina avahi-daemon[323]: Leaving mDNS multicast group on interface wlan0.IPv4 with address 169.254.118.239.
apr 19 16:55:43 rpicasina avahi-daemon[323]: Interface wlan0.IPv4 no longer relevant for mDNS.
apr 19 16:55:44 rpicasina kernel: wlan0: authenticate with 10:13:31:ca:19:6d
apr 19 16:55:44 rpicasina kernel: wlan0: send auth to 10:13:31:ca:19:6d (try 1/3)
apr 19 16:55:44 rpicasina kernel: wlan0: authenticated
apr 19 16:55:44 rpicasina kernel: wlan0: associate with 10:13:31:ca:19:6d (try 1/3)
apr 19 16:55:44 rpicasina kernel: wlan0: RX AssocResp from 10:13:31:ca:19:6d (capab=0x1011 status=0 aid=1)
apr 19 16:55:44 rpicasina kernel: wlan0: associated
apr 19 16:55:44 rpicasina dhcpcd[3974]: wlan0: carrier acquired
apr 19 16:55:44 rpicasina kernel: IPv6: ADDRCONF(NETDEV_CHANGE): wlan0: link becomes ready
apr 19 16:55:44 rpicasina dhcpcd[3974]: wlan0: IAID 06:10:32:88
apr 19 16:55:44 rpicasina dhcpcd[3974]: wlan0: adding address fe80::ec34:fad0:796d:7d27
apr 19 16:55:44 rpicasina avahi-daemon[323]: Joining mDNS multicast group on interface wlan0.IPv6 with address fe80::ec34:fad0:796d:7d27.
apr 19 16:55:44 rpicasina avahi-daemon[323]: New relevant interface wlan0.IPv6 for mDNS.
apr 19 16:55:44 rpicasina avahi-daemon[323]: Registering new address record for fe80::ec34:fad0:796d:7d27 on wlan0.*.
apr 19 16:55:44 rpicasina dhcpcd[3974]: wlan0: soliciting an IPv6 router
apr 19 16:55:44 rpicasina dhcpcd[3974]: wlan0: soliciting a DHCP lease
apr 19 16:55:44 rpicasina dhcpcd[3974]: wlan0: offered 192.168.1.6 from 192.168.1.1
apr 19 16:55:44 rpicasina dhcpcd[3974]: wlan0: probing address 192.168.1.6/24
apr 19 16:55:49 rpicasina dhcpcd[3974]: wlan0: leased 192.168.1.6 for 3600 seconds
apr 19 16:55:49 rpicasina dhcpcd[3974]: wlan0: adding route to 192.168.1.0/24
apr 19 16:55:49 rpicasina avahi-daemon[323]: Joining mDNS multicast group on interface wlan0.IPv4 with address 192.168.1.6.
apr 19 16:55:49 rpicasina dhcpcd[3974]: wlan0: adding default route via 192.168.1.1
apr 19 16:55:49 rpicasina avahi-daemon[323]: New relevant interface wlan0.IPv4 for mDNS.
apr 19 16:55:49 rpicasina avahi-daemon[323]: Registering new address record for 192.168.1.6 on wlan0.IPv4.

Running an up to date raspbian. It has worked for like 2 years on ethernet and the same approach (ip assigned on the router). I have run a very old orange pi in the same position via wifi. It used to reconnect 2-3 times a day but never get a problem of missing ip address.

At the moment I cannot change ip to my server, since I have several IoT devices that connects to it. I wish at some point in the future to be able to get an ethernet cable there, but this is not a possibility at the moment.

Any idea?

1

The problem was probably related to the usb wifi dongle in use.

I have replace that with a:

Ralink Technology, Corp. RT5370 Wireless Adapter

and that specific problem never occurred again.

This wifi card reports a worse signal (in the same position) but, apart from that, every time it lost the carrier is able to reconnect and be back on my network.

The following logs are related to every disconnection with the "new" card, I think I could consider this problem "fixed".

$ journalctl -u dhcpcd | grep lost
apr 19 18:25:22 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 18:26:13 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 19:25:27 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 19:25:38 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 19:25:39 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 19:26:45 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 19:26:53 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 20:35:31 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 20:36:59 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 22:07:00 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 22:07:08 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 23:37:07 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 19 23:37:08 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 02:37:10 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 02:37:13 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 05:37:21 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 14:37:42 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 14:37:43 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 17:37:46 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 17:37:49 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 19:07:50 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 19:07:57 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 20:37:53 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 20:37:56 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 22:08:00 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 20 22:08:01 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 01:08:04 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 01:08:05 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 02:38:11 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 02:38:12 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 04:08:11 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 04:08:14 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 07:08:19 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 07:08:27 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 08:38:22 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 08:38:23 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 10:08:26 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 10:08:33 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 11:38:29 rpicasina dhcpcd[364]: wlan0: carrier lost
apr 21 11:38:32 rpicasina dhcpcd[364]: wlan0: carrier lost
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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