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?