3

I've got a Raspberry Pi 2 running Raspbian (can't remember the exact date but it's something from early February 2017) and when connected to my router (TP-Link TD-W8970) it fails to get a DHCP allocated address more often than it succeeds (gets one maybe one in five boots).

Because of how the box is being used it needs to be on a fixed IP, but I prefer to assign this at the router level rather than setting up the device individually.

The Pi has been fully updated/upgraded so all packages are up to date.

How do I go about diagnosing why the Pi fails to get an IP on boot? For the record, as a temporary fix, I set a fixed IP address in /etc/dhcpcd.conf but I want to avoid this if possible.

  • Run tcpdump and capture the traffic at the time it's attempting to do DHCP negotiation. This may lead you to find where things are breaking down. (There's also Wireshark if you're more familiar with the GUI way of doing things). – stevieb Mar 14 '17 at 14:15
  • how can i run tcpdump during boot? if i bring the interface down/up after boot or force a refresh that seems to work, it's only during boot that it seems to fail, or can i run from another machine in promiscuous mode to see whats needed? – James Kent Mar 14 '17 at 14:28
  • Oh, I apologize. I assumed that you could reproduce the issue after booting was completed. Running it on another box in promiscuous mode likely won't help much, as some the return traffic will be directed at the MAC directly and not broadcast. – stevieb Mar 14 '17 at 15:07
  • it was a little while ago that i was properly working on it, reason i'm looking at it again now is that i had to change the dhcp range of my network and as the box is run headless normally i had a bit of a headache trying to get into it to change it to the new range, i will try and see if i can replicate it again tonight and see what happens. – James Kent Mar 14 '17 at 15:52
  • Are you saying that you will get the connection 100% when setup a fixed IP via /etc/dhcpcd.conf? but when letting the router to assign IP via DHCP, it will have an intermittent results? – hcheung Mar 15 '17 at 12:51
0

I have not tried this on the problem described, so YMMV, as they say, but there are logging options in dhcpd.conf This certainly will not do any harm and may get you 'nearer' the problem.

| improve this answer | |
  • that link is for the dhcpd daemon, not for dhcpcd as usch it deals with the server not the client. i'm having problems with the client end, so nothing in that link can be used on this problem, but i will look to see if there is something similar for the correct process. – James Kent Mar 14 '17 at 14:55
  • Yes, understand, but (IMO) worth looking at both ends of it. Good luck. – Hugh Barnard Mar 15 '17 at 8:56
  • but i can't loom at both ends... the dhcp server is running on the router, i cannot get at any logs or config options for it other than that exposed through the web interface, therefore there is nothing i can do from this end. and also note that with at least 30 other devices in the house, this pi is the only one that has difficult getting an IP. – James Kent Mar 15 '17 at 9:14
0

I'd advise that you use /etc/network/interfaces for configuring your network rather than the dhcpcd.conf

It works without fail for me, here's my config;

auto lo
iface lo inet loopback
auto eth0
iface eth0 inet dhcp

Also, is it a wired or wireless connection you have to the router?

HTH,

Paul

| improve this answer | |
  • firstly my entries in /etc/network/interfaces match yours, that doesn't change the fact that dhcpcd is still used to get the IP from the server and this is failing. and i have had this problem with both wired and wireless connections. – James Kent Mar 15 '17 at 10:32
  • Can you post your dhcpcd.conf please? – Tullio_IRL Mar 15 '17 at 12:14
  • In fact, since release of Jessie, it is recommended to configure network via dhcpcd.conf than messing with /etc/network/interfaces. – hcheung Mar 15 '17 at 12:42
0

not that this is likely to help anyone in any way, but my issue seems to have been related specifically to the router/pi OS combinations I was using.

devices that worked fine:

  • a Pi 1B running an older version of raspbian (wheezy)
  • a pi3 running openelec or OSMC
  • Windows 7 or 10
  • Android (5, 5.1, 7, 7.1 tested)
  • ubuntu in VM
  • xp in VM
  • fitbit scales
  • ESP8266 device
  • iphone 4S

the only device with an issue was Pi 2B running jessie, i believe this must either be down to the router or Pi dhcp software not strictly following the standard, not sure how or why, but using a different router all the issues go away. for the record the router was a TP link TD8970, the router that has replaced it is a plusnet hub one.

| 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.