Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DHCP offers not being accepted #17

Open
dbrb2 opened this issue Jun 6, 2022 · 9 comments
Open

DHCP offers not being accepted #17

dbrb2 opened this issue Jun 6, 2022 · 9 comments

Comments

@dbrb2
Copy link

dbrb2 commented Jun 6, 2022

I have this set up on a pi to which a laptop is connected. The pi has a wifi and a wired interface, and the wired interface is connected directly to a laptop.

The pi is running the python DHCP server, whilst the laptop is requesting an IP

I can see the DHCP discovery messages coming in from the laptop to the Pi, and the Pi responds with an offer

However, the offer is never accepted - there seems to be no REQUEST message sent in response by the laptop - so the logs on the pi show a continuous stream of "DHCPDISCOVER", "DHCPOFFER"

discover:
Message Type: 1
client MAC address: 00:0E:C6:CA:BC:35
client IP address: 0.0.0.0
your IP address: 0.0.0.0
next server IP address: 0.0.0.0
client identifier: 01:00:0E:C6:CA:BC
dhcp message type: DHCPDISCOVER
host name: ben-laptop
maximum dhcp message size: 576
parameter request list: [1, 2, 6, 12, 15, 26, 28, 121, 3, 33, 40, 41, 42, 119, 249, 252, 17]

new ip: 192.168.2.6
add 00:0E:C6:CA:BC:35 192.168.2.6 ben-laptop
broadcasting:
Message Type: 2
client MAC address: 00:0E:C6:CA:BC:35
client IP address: 0.0.0.0
your IP address: 192.168.2.6
next server IP address: 0.0.0.0
broadcast address: 255.255.255.255
client identifier: 00:0E:C6:CA:BC:35
dhcp message type: DHCPOFFER
ip address lease time: 300
subnet mask: 255.255.255.0

Running wireshark on the laptop - the one issuing the DISCOVER messages, I can see the DHCPOFFER, but it seems a REQUEST response is never sent

Dynamic Host Configuration Protocol (Offer)
Message type: Boot Reply (2)
Hardware type: Ethernet (0x01)
Hardware address length: 6
Hops: 0
Transaction ID: 0x2eb6bcda
Seconds elapsed: 0
Bootp flags: 0x0001 (Unicast)
Client IP address: 0.0.0.0
Your (client) IP address: 192.168.2.6
Next server IP address: 0.0.0.0
Relay agent IP address: 0.0.0.0
Client MAC address: AsixElec_ca:bc:35 (00:0e:c6:ca:bc:35)
Client hardware address padding: 00000000000000000000
Server host name not given
Boot file name not given
Magic cookie: DHCP
Option: (1) Subnet Mask (255.255.255.0)
Length: 4
Subnet Mask: 255.255.255.0
Option: (28) Broadcast Address (192.168.2.255)
Length: 4
Broadcast Address: 192.168.2.255
Option: (51) IP Address Lease Time
Length: 4
IP Address Lease Time: (300s) 5 minutes
Option: (53) DHCP Message Type (Offer)
Length: 1
DHCP: Offer (2)
Option: (61) Client identifier
Length: 6
Type: 0
Client Identifier: \016���5
Option: (255) End
Option End: 255

@dbrb2 dbrb2 changed the title Bad checksum on DHCP offer DHCP offers not being accepted Jun 6, 2022
@dbrb2 dbrb2 changed the title DHCP offers not being accepted DHCP offers not being received - problem with broadcasts? Jun 6, 2022
@niccokunzmann
Copy link
Owner

niccokunzmann commented Jun 12, 2022 via email

@dbrb2
Copy link
Author

dbrb2 commented Jun 12, 2022

Sorry for the confusion:

I have the python script running on a raspberryPi
I have a laptop connected to the wired interface of the pi

The laptop is making DHCP DISCOVER messages, which I can see using tshark on the pi
in response to these messages, the pi is sending a DHCP OFFER message to the broadcast IP, which I can see arriving at the laptop using wireshark

However, for some reason that incoming DHCP OFFER is never accepted by the laptop - no REQUEST message is sent from the laptop to the pi in response to the OFFER, and instead a new DISCOVERY is sent

I can't see any obvious problem with the offer message. The only thing that I noticed is that the OFFER is broadcast, rather than unicast. As far as I can see, either should work - though unicast offers (with the destination set to the mac of the client) seem to be a little more common.

@dbrb2 dbrb2 changed the title DHCP offers not being received - problem with broadcasts? DHCP offers not being accepted Jun 12, 2022
@niccokunzmann
Copy link
Owner

niccokunzmann commented Jun 15, 2022 via email

@dbrb2
Copy link
Author

dbrb2 commented Jun 15, 2022 via email

@niccokunzmann
Copy link
Owner

niccokunzmann commented Jun 24, 2022 via email

@SurajBhari
Copy link

I used multicast. It is probably not hard to use unicast.

hey, I tried to run this today with no experince in networking at all. and I had same issue as said by the OP.
but as of the time I am writing this. i can see that you have set the flag to unicast.
am I missing something ?

@niccokunzmann
Copy link
Owner

oh, it is a while ago that I wrote this program, so if you can make it work by changing the flag, that is nice, PR welcome.

It seems to me that the MAC address should be set to send an offer. Would you like to modify the code and have a look if it solves your problem?

@SurajBhari
Copy link

hey, I have tried to set it to both ways multicast and unicast (by changing bootp_flags variable) and also setting up client_mac_address. but it was still the same.

Just to be sure we are on the same page. can you share your testbench?
I am using this on my laptop as server and a desktop running ubuntu 22 by a single LAN wire.

@Xenoamor
Copy link

Xenoamor commented Feb 7, 2024

I've encountered the same problem when trying to process a DHCP Discover from an embedded device running a udhcp client. It looks to be that this client does not handle broadcasted DHCP Offers and instead expects the ethernet frame address to be its MAC address

Basically my client insists on a unicast offer with the destination as it's MAC address. It will not listen to a broadcasted multicast offer

Unfortunately python does not natively support setting this low level field on Windows without using something like NpCap. Thus I don't believe this can be done in standard python alone

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants