hollymcr
Posts: 15
Joined: Thu Feb 11, 2016 7:15 pm

Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 1:38 pm

My Pi currently has 3 IP addresses on my network via wifi (one of which is also the Ethernet IP).

Any suggestions why, or how I can work out why?

To complicate things (maybe, anyway): It is running Debian 10 (Buster) but as an upgrade from 9 (Stretch) so it may be related to that. It is also running on read-only filesystem (/var/lib/dhcpcd5 is writeable though). A consequence of this arrangement is that although it's been running I don't have many logs to look back on; only one of the IP addresses appears in syslog today

epoch1970
Posts: 4787
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 1:53 pm

Trying to fix the issue on a semi-broken system could be a waste of time...

If you wish,
post the output of "ip link show" "ip address show" "ip route show"
and also
the contents of /etc/cmdline.txt, /etc/network/interfaces, /etc/dhcpcd.conf
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

User avatar
DougieLawson
Posts: 38511
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 2:28 pm

What changes have you made to /etc/network/interfaces? Undo everything in there.

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

hollymcr
Posts: 15
Joined: Thu Feb 11, 2016 7:15 pm

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 2:31 pm

DougieLawson wrote:
Mon Jul 29, 2019 2:28 pm
What changes have you made to /etc/network/interfaces? Undo everything in there.

Code: Select all

# interfaces(5) file used by ifup(8) and ifdown(8)

# Please note that this file is written to be used with dhcpcd
# For static IP, consult /etc/dhcpcd.conf and 'man dhcpcd.conf'

# Include files from /etc/network/interfaces.d:
source-directory /etc/network/interfaces.d
Mine is as your example (and /etc/network/interfaces.d is empty).

User avatar
DougieLawson
Posts: 38511
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 2:33 pm

Reboot your router.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

hollymcr
Posts: 15
Joined: Thu Feb 11, 2016 7:15 pm

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 2:49 pm

epoch1970 wrote:
Mon Jul 29, 2019 1:53 pm
Trying to fix the issue on a semi-broken system could be a waste of time...
You may call it broken....

The fact that it's running on a read-only system is obviously not accidental. The upgrade from stretch (because I want to test it on a Pi4 at some point) might have ideally been better as a clean install but my initial attempts at that weren't fruitful because my existing image has too many tweaks (albeit not much to the network stack so *should* be irrelevant). But I didn't want to waste anyone's time by not giving the full picture.
epoch1970 wrote:
Mon Jul 29, 2019 1:53 pm
If you wish,
post the output of "ip link show" "ip address show" "ip route show"
and also
the contents of /etc/cmdline.txt, /etc/network/interfaces, /etc/dhcpcd.conf
Since I posted I have found a possible cause: a script which tries to maintain a working wifi connection by restarting it if it cannot ping its default gateway. However since the upgrade, ping no longer worked without root permissions so the script was failing the test and restarting dhcpcd. Reinstalling iptools resolved that.

Aside from lots of unnecessary dhcpcd restarts I cannot see why this could have left me with multiple IP addresses, but I decided at that point it was safer to restart and pick up the diagostics if/when it recurred, and it was when I came back here to post that update I saw your message. So I can't give you the ip command output right now. As to the others:

cmdline.txt:

Code: Select all

dwc_otg.lpm_enable=0 console=tty1 root=/dev/mmcblk0p2 rootfstype=ext4 elevator=deadline fsck.repair=yes rootwait fastboot noswap ro quiet splash plymouth.ignore-serial-consoles logo.nologo loglevel=3 vt.global_cursor_default=0
dhcpcd.conf and network/interfaces are as per stock.

hollymcr
Posts: 15
Joined: Thu Feb 11, 2016 7:15 pm

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 2:53 pm

DougieLawson wrote:
Mon Jul 29, 2019 2:33 pm
Reboot your router.
Can I ask why that might cause the Pi to have multiple IP addresses? If I can work out what might have caused it that gives me something I can test.

As it happens the router is set to reboot nightly anyway (and my logs go back far enough to know that the other IP addresses pre-date that). I've also replaced my wifi AP in the last few days and I wondered whether that might influence it. (DHCP comes from the router not the AP but I'm highlighting that they're not the same box.)

epoch1970
Posts: 4787
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 2:55 pm

(Usually an RO system is the result of an accident or a defect.)
The cmdline.txt was to check if you were using kernel level IP config, with ip=xxx.
You're not, the other files are stock, I would suspect the effects of the script.
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

hollymcr
Posts: 15
Joined: Thu Feb 11, 2016 7:15 pm

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 3:19 pm

epoch1970 wrote:
Mon Jul 29, 2019 2:55 pm
(Usually an RO system is the result of an accident or a defect.)
Ah, fair enough. No, this isn't a kernel trying to protect itself, this is a Pi I'm trying to make robust enough to handle unplanned power loss. /var/log/dhcpcd is a symlink to /tmp (which is in memory).
The cmdline.txt was to check if you were using kernel level IP config, with ip=xxx.
You're not, the other files are stock, I would suspect the effects of the script.
Interesting, didn't know about the ip= kernel parameter.

Having Googled before I posted, one potential cause (not relevant here as far as I can tell) would be multiple dhcp instances (eg having more than one dhcp client installed). That makes me wonder if the dhcpcd restarts (which were roughly every minute) might have resulted in two dhcpcd processes overlapping somehow (it'd been up for several days before I noticed, and rare edge cases can show themselves when tested every minute for several weeks). It's my best guess at the moment, anyway.

epoch1970
Posts: 4787
Joined: Thu May 05, 2016 9:33 am
Location: Paris, France

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 3:44 pm

hollymcr wrote:
Mon Jul 29, 2019 3:19 pm
/var/log/dhcpcd is a symlink to /tmp (which is in memory).
/var/lib you mean?
See this https://wiki.archlinux.org/index.php/dh ... DHCP_lease
I suspect your trouble comes from the multiple restarts combined with a little too much RO filesystem. Perhaps in combination with the behavior of the DHCP server.
Clearly if dhcpcd dies abruptly it does not release the IP to the server, so requests pile-up...
"S'il n'y a pas de solution, c'est qu'il n'y a pas de problème." Les Shadoks, J. Rouxel

hollymcr
Posts: 15
Joined: Thu Feb 11, 2016 7:15 pm

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 4:41 pm

epoch1970 wrote:
Mon Jul 29, 2019 3:44 pm
/var/lib you mean?
Yes, sorry.
See this https://wiki.archlinux.org/index.php/dh ... DHCP_lease
I suspect your trouble comes from the multiple restarts combined with a little too much RO filesystem. Perhaps in combination with the behavior of the DHCP server.
The above is why it's now in /tmp; it'll get lost on a reboot and is writeable/deletable whilst the unit is running if the lease changes.
Clearly if dhcpcd dies abruptly it does not release the IP to the server, so requests pile-up...
I'm not sure what you mean here in terms of requests piling up?

User avatar
DougieLawson
Posts: 38511
Joined: Sun Jun 16, 2013 11:19 pm
Location: A small cave in deepest darkest Basingstoke, UK
Contact: Website Twitter

Re: Pi3/Buster - Wifi getting assigned multiple IP via DHCP

Mon Jul 29, 2019 4:58 pm

hollymcr wrote:
Mon Jul 29, 2019 2:53 pm
DougieLawson wrote:
Mon Jul 29, 2019 2:33 pm
Reboot your router.
Can I ask why that might cause the Pi to have multiple IP addresses? If I can work out what might have caused it that gives me something I can test.

As it happens the router is set to reboot nightly anyway (and my logs go back far enough to know that the other IP addresses pre-date that). I've also replaced my wifi AP in the last few days and I wondered whether that might influence it. (DHCP comes from the router not the AP but I'm highlighting that they're not the same box.)
Because, the router runs the DHCP server (unless there's more info you've not told us) and rebooting it will clean up its DHCP tables.
Note: Any requirement to use a crystal ball or mind reading will result in me ignoring your question.

I'll do your homework for you for a suitable fee.

Any DMs sent on Twitter will be answered next month.
All non-medical doctors are on my foes list.

Return to “Troubleshooting”