Options

DHCP question

JasionoJasiono Member Posts: 896 ■■■■□□□□□□
When there is a DHCP server sitting on a different subnet, and a discover message is relayed to that DHCP server, does the server use the source address from the message to calculate what subnet to pull and offer an IP address from?

And if the DHCP server sits on the same subnet as the client requesting an IP address, does it just use the subnet it currently resides on since it knows that a source address of 0.0.0.0 means it's coming from the same subnet?

I understand the concept of DHCP and know how to set it up, but knowing what subnet to pull an address from wasn't explained in the book I'm reading, and this is the only explanation that I could come up with.

Am I correct?

Comments

  • Options
    Fulcrum45Fulcrum45 Member Posts: 621 ■■■■■□□□□□
    Good question. I believe that until it gets an IP via the DHCP server it can only broadcast (255.255.255.255) for a DHCP server. And it can only get that IP address if its on the same broadcast domain as the server (router) itself. Does it take note what interface it comes in on and matches that to the proper DHCP pool with a similar Network setting? This is totally a guess because like you I'm not entirely sure either.
  • Options
    JasionoJasiono Member Posts: 896 ■■■■□□□□□□
    If a company has a centralized dhcp server you have to set up each router on every subnet to essentially forward the broadcast for the dhcp server to the dhcp server on the other network. That's the DHCP relay.

    What happens is the router receives the discover packet with the destination address of 255.255.255.255 coming from source 0.0.0.0. Usually, by default, routers will ignore broadcast messages.

    If set up with dhcp relay, it takes that packet, attaches it's own interfaces IP address as the source and sends it to the specified dhcp server ip address that was within the ip helper-address command.

    The server processes it, sends it back to the router it came from, the router takes it and broadcasts it back to the network in which the interface resides on so that the addressless host can process the information.

    It just makes sense to me that the DHCP server takes the source address that the router attached to the DHCP discover message to find out what subnet pool to go into to pull an address.

    Unless there is something else happening when you configure your routers to be the DHCP server. I don't understand fully.

    Should I understand how that part works or just say it's magic, the DHCP server will know what subnet ?
  • Options
    JasionoJasiono Member Posts: 896 ■■■■□□□□□□
    The fact that you have a CCENT and that is what I am studying for, and you don't know either, shows me that it's something I should not be concerned with too much (at this level anyway).
  • Options
    d4nz1gd4nz1g Member Posts: 464
    First of all, TL/DR icon_redface.gif


    The router intercept the discover (broadcast) and relays the request to the ip helper address configured on the given interface as unicast, specifying the network on which the packet was received.

    Confusing?

    Ex: A router receives a dhcp discover message on its Fa0/0 interface, which is configured with 1.1.1.1/24 address. The router will then relay to the dhcp server (configured with the ip helper command, under Fa0/0) and will tell the dhcp server that the address of the scope must match the 1.1.1.0/24 network.

    Hope it helps!
  • Options
    JasionoJasiono Member Posts: 896 ■■■■□□□□□□
    Yeah that makes a lot of sense and that's what I was assuming, but that brings up this question:

    Is the router telling the DHCP server what pool to choose the address from due to a configuration, or is the DHCP server looking at the source address that the router put into the packet to make it's assumption?
  • Options
    james43026james43026 Member Posts: 303 ■■□□□□□□□□
    Everyone is pretty close on how this actually works. When a Cisco router interface has been configured as a DHCP relay, then any DHCP broadcasts that arrive at that interface will be unicasted to the IP address specified in the IP helper command, and a new field will be inserted into the IP packet called the "giaddr" field, this field will contain the IP address of the router interface that received the broadcast (this field is what tells the DHCP server what pool of addresses / subnet to use for this request), the source address of the IP Packet will also be the same as the giaddr field.
  • Options
    NansNans Member Posts: 160
    Jasiono wrote: »
    When there is a DHCP server sitting on a different subnet, and a discover message is relayed to that DHCP server, does the server use the source address from the message to calculate what subnet to pull and offer an IP address from?

    And if the DHCP server sits on the same subnet as the client requesting an IP address, does it just use the subnet it currently resides on since it knows that a source address of 0.0.0.0 means it's coming from the same subnet?


    I understand the concept of DHCP and know how to set it up, but knowing what subnet to pull an address from wasn't explained in the book I'm reading, and this is the only explanation that I could come up with.

    Am I correct?

    I guess this is what you are asking for you have a single DHCP server in the entire company and you want it to handle all the requests. And this DHCP server is running 3 routers away from where you send a request and this is the case with all the different routers and each has switches which has different vlans with all different subnets. So I guess your question is will the router be able to provided the hosts with the correct address for a particular VLAN with the subnet it is configured for.

    Yes. Because the relay router forward's the query if you configure it with the IP Helper-address.How? When the query is fowarded by the router it will be not be a broadcast and will be directed to that particular server and this will include where it came from i.e is the default gateway and you should already know this each vlan will be having its own gateway for the Inter-VLAN routing. So if the server was configured to provide addresses for that subnet and when it receives the query form that gateway then it will know which address to provide and replies with the next available address in that subnet for that particular VLAN.

    Hope this helps and there is no point of confusion how many ever subnets you use in your company but I think what you need is a request from the appropriate gateway will always result in correct address allocation.

    As always please correct em if I am wrong.

    Regards
    2016 Certification Goals: CCNP Route /COLOR][B][/B][I][B]X[/B][/I][COLOR=#008000-->Switch/COLOR]:study:[COLOR=#ff8c00-->TShoot[], CCDP []
  • Options
    DPN1DPN1 Member Posts: 35 ■■□□□□□□□□
    I had a DHCP question about what it would do if there was a conflict. That was the only one I got on it.
  • Options
    JasionoJasiono Member Posts: 896 ■■■■□□□□□□
    You guys rock, thanks so much for all the explanations.
  • Options
    aderonaderon Member Posts: 404 ■■■■□□□□□□
    For literally anything you could ever want to know about DHCP: http://tools.ietf.org/html/rfc2131
    2019 Certification/Degree Goals: AWS CSA Renewal (In Progress), M.S. Cybersecurity (In Progress), CCNA R&S Renewal (Not Started)
  • Options
    ZartanasaurusZartanasaurus Member Posts: 2,008 ■■■■■■■■■□
    james43026 wrote: »
    Everyone is pretty close on how this actually works. When a Cisco router interface has been configured as a DHCP relay, then any DHCP broadcasts that arrive at that interface will be unicasted to the IP address specified in the IP helper command, and a new field will be inserted into the IP packet called the "giaddr" field, this field will contain the IP address of the router interface that received the broadcast (this field is what tells the DHCP server what pool of addresses / subnet to use for this request), the source address of the IP Packet will also be the same as the giaddr field.
    Winner winner.

    Now, what happens if it forwards a DHCP request from an interface configured with a secondary IP and there's no DHCP pool for the primary IP? :)
    Currently reading:
    IPSec VPN Design 44%
    Mastering VMWare vSphere 5​ 42.8%
  • Options
    james43026james43026 Member Posts: 303 ■■□□□□□□□□
    Winner winner.

    Now, what happens if it forwards a DHCP request from an interface configured with a secondary IP and there's no DHCP pool for the primary IP? :)

    In this scenario, no IP address would be pulled from the DHCP server, because by default the Cisco DHCP relay agent will not try the secondary IP. But this could be fixed by applying the "IP DHCP smart-relay" option from router config, this allows the router to insert the secondary IP on the receiving interface into the "giaddr", and assuming the secondary IP has a valid IP pool on the DHCP server, you would then get an IP address in the secondary IP addresses subnet, the Primary IP will still be tried on every DHCP request first, but once the router sees that no DHCPOFFER packet has been sent back, the router will try the secondary IP. Not sure how long the router waits though after trying the primary IP address.

    Chicken dinner?
  • Options
    JasionoJasiono Member Posts: 896 ■■■■□□□□□□
Sign In or Register to comment.