Giter Club home page Giter Club logo

Comments (5)

hugelgupf avatar hugelgupf commented on June 12, 2024 1

I'd think this is your server not replying with the correct hostname. Do you suspect that the DHCP client is setting that hostname? Have you looked at what the packet looks like on the wire (tcpdump)?

from dhcp.

andrewrynhard avatar andrewrynhard commented on June 12, 2024

@hugelgupf here is output from sudo dhcpdump -i enp5s0 using the above code:

  TIME: 2019-02-24 18:41:50.470
    IP: 192.168.124.128 (50:46:5d:8a:e7:9f) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
    OP: 1 (BOOTPREQUEST)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: 3e6f933a
  SECS: 0
 FLAGS: 7f80
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: 50:46:5d:8a:e7:9f:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         1 (DHCPDISCOVER)
OPTION:  55 (  5) Parameter Request List      1 (Subnet mask)
					      3 (Routers)
					     15 (Domainname)
					      6 (DNS server)
					     12 (Host name)

---------------------------------------------------------------------------

  TIME: 2019-02-24 18:41:50.470
    IP: 192.168.124.1 (7a:8a:20:f6:87:46) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
    OP: 2 (BOOTPREPLY)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: 3e6f933a
  SECS: 0
 FLAGS: 7f80
CIADDR: 0.0.0.0
YIADDR: 192.168.124.128
SIADDR: 192.168.124.1
GIADDR: 0.0.0.0
CHADDR: 50:46:5d:8a:e7:9f:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         2 (DHCPOFFER)
OPTION:  54 (  4) Server identifier         192.168.124.1
OPTION:  51 (  4) IP address leasetime      43200 (12h)
OPTION:  58 (  4) T1                        21600 (6h)
OPTION:  59 (  4) T2                        37800 (10h30m)
OPTION:   1 (  4) Subnet mask               255.255.255.0
OPTION:  28 (  4) Broadcast address         192.168.124.255
OPTION:  26 (  2) Interface MTU             1500
OPTION:   3 (  4) Routers                   192.168.124.1
OPTION:   6 (  4) DNS server                192.168.124.1
---------------------------------------------------------------------------

I don't see OPTION: 12 ( 4) Host name dkr1 in the reply as I do with dhclient:

  TIME: 2019-02-24 18:42:28.123
    IP: 0.0.0.0 (50:46:5d:8a:e7:9f) > 255.255.255.255 (ff:ff:ff:ff:ff:ff)
    OP: 1 (BOOTPREQUEST)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: 6c42dc09
  SECS: 0
 FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 0.0.0.0
SIADDR: 0.0.0.0
GIADDR: 0.0.0.0
CHADDR: 50:46:5d:8a:e7:9f:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         3 (DHCPREQUEST)
OPTION:  50 (  4) Request IP address        192.168.124.128
OPTION:  12 (  4) Host name                 dkr1
OPTION:  55 ( 13) Parameter Request List      1 (Subnet mask)
					     28 (Broadcast address)
					      2 (Time offset)
					      3 (Routers)
					     15 (Domainname)
					      6 (DNS server)
					    119 (Domain Search)
					     12 (Host name)
					     44 (NetBIOS name server)
					     47 (NetBIOS scope)
					     26 (Interface MTU)
					    121 (Classless Static Route)
					     42 (NTP servers)

---------------------------------------------------------------------------

  TIME: 2019-02-24 18:42:28.124
    IP: 192.168.124.1 (7a:8a:20:f6:87:46) > 192.168.124.100 (1a:56:47:82:13:a0)
    OP: 2 (BOOTPREPLY)
 HTYPE: 1 (Ethernet)
  HLEN: 6
  HOPS: 0
   XID: ff5c4454
  SECS: 0
 FLAGS: 0
CIADDR: 0.0.0.0
YIADDR: 192.168.124.100
SIADDR: 192.168.124.1
GIADDR: 0.0.0.0
CHADDR: 1a:56:47:82:13:a0:00:00:00:00:00:00:00:00:00:00
 SNAME: .
 FNAME: .
OPTION:  53 (  1) DHCP message type         5 (DHCPACK)
OPTION:  54 (  4) Server identifier         192.168.124.1
OPTION:  51 (  4) IP address leasetime      43200 (12h)
OPTION:  58 (  4) T1                        21600 (6h)
OPTION:  59 (  4) T2                        37800 (10h30m)
OPTION:   1 (  4) Subnet mask               255.255.255.0
OPTION:  12 (  4) Host name                 dkr1
OPTION:  28 (  4) Broadcast address         192.168.124.255
OPTION:  26 (  2) Interface MTU             1500
OPTION:   3 (  4) Routers                   192.168.124.1
OPTION:   6 (  4) DNS server                192.168.124.1

from dhcp.

hugelgupf avatar hugelgupf commented on June 12, 2024

Those are different hosts with different hostnames. I'd really like to see what tcpdump on the server looks like, if you can swing it, to see what bytes it is putting on the wire.

The parsing code for HostName() is fairly simple, and "localhost" is as far as I can tell not even a string I can find in the dhcpv4 library. Next, I'd have three points of "where to look":

  • while the server is supposed to return the same options for both the offer and the ack, you're looking at the Offer packet while dhclient looks at the Ack. I'm curious if the Ack packet has a different hostname. (Note that #250 improves the API for Exchange and just returns the correct offer and ack packets.)

  • if tcpdump at the server or somewhere in the middle indicates that "localhost" was sent; I'd suspect either server misconfig (though you show it seems to work for others, so less likely) or that we screwed up how the client is identified by the server (I assume Mac address?). I'd suspect the latter?

  • in client4, it'd be interesting to see what the payload variable in SendReceive contains right before dhcpv4.FromBytes is called. This'd be a more complicated way of finding out what was actually on the wire.

My money is on "we screwed up the identifier," but it's still weird.

from dhcp.

andrewrynhard avatar andrewrynhard commented on June 12, 2024

@hugelgupf Thanks. I seemed to have borked my KVM setup, VMs timing out on DHCP now :D. As soon as I get that figured out I will get back to you!

from dhcp.

pmazzini avatar pmazzini commented on June 12, 2024

Shall I close this?

from dhcp.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.