Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


Trying to remember how bootp and dhcp work to assign addresses.
New on LowEndTalk? Please Register and read our Community Rules.

All new Registrations are manually reviewed and approved, so a short delay after registration may occur before your account becomes active.

Trying to remember how bootp and dhcp work to assign addresses.

CoreyCorey Member
edited August 2018 in Help

So I am aware I have bootp setup to route dhcp broadcast packets from my different vlans to a central dhcp server. On that central dhcp server I have the following in /var/log/messages


Aug 2 21:38:12 main dhcpd: DHCPDISCOVER from 00:25:90:a1:ef:4c via 10.0.22.1
Aug 2 21:38:13 main dhcpd: DHCPOFFER on 10.0.22.3 to 00:25:90:a1:ef:4c via 10.0.22.1
Aug 2 21:38:13 main dhcpd: DHCPDISCOVER from 00:25:90:a1:ef:4c via 10.0.22.1
Aug 2 21:38:13 main dhcpd: DHCPOFFER on 10.0.22.3 to 00:25:90:a1:ef:4c via 10.0.22.1
Aug 2 21:38:15 main dhcpd: DHCPREQUEST for 10.0.22.3 (10.0.0.2) from 00:25:90:a1:ef:4c via 10.0.22.1
Aug 2 21:38:15 main dhcpd: DHCPACK on 10.0.22.3 to 00:25:90:a1:ef:4c via 10.0.22.1

How in the world does the request come from the gateway 10.0.22.1 of an assigned range on the interface? I know I'm matching to see what network the request comes from on my DHCP server to tell what address I am going to give. EX:


subnet 10.0.22.0 netmask 255.255.255.0{
option subnet-mask 255.255.255.0;
option routers 10.0.22.1;
range dynamic-bootp 10.0.22.2 10.0.22.254;
}

I could have multiple ip ranges assigned to an interface on my router, so how does it get decided what gateway these requests come from? Does it just come from the 'first' assigned ip range?

Comments

  • It's the address of the device running the DHCP helper, although I'm not actually sure what would happen if the interface on the device had multiple subnets present.

    I suspect it may also vary depending on the implementation.

  • hostfavhostfav Member, Host Rep
    default-lease-time 600;
    max-lease-time 7200;
    option subnet-mask 255.255.255.224;
    option broadcast-address 2x.x.x.31;
    option routers 2x.x.x.1;
    
    shared-network kvmnet{
      subnet 2x.x.x.0 netmask 255.255.255.224 {
            option subnet-mask 255.255.255.224;
            option broadcast-address 2x.x.x.31;
            option routers 2x.x.x.1;
            option domain-name-servers 8.8.8.8, 8.8.4.4;
            }
    
      subnet 2x.x.x.216 netmask 255.255.255.248 {
            option subnet-mask 255.255.255.248;
            option broadcast-address 2x.x.x.223;
            option routers 2x.x.x.217;
            option domain-name-servers 8.8.8.8, 8.8.4.4;
    
            }
    
     subnet 2x.x.x.64 netmask 255.255.255.192 {
            option subnet-mask 255.255.255.192;
            option broadcast-address 2x.x.x.127;
            option routers 2x.x.x.65;
            option domain-name-servers 8.8.8.8, 8.8.4.4;
    
        host 129-1 {hardware ethernet BA:CD:05:FA:3D:89;fixed-address 2x.x.x.90;}
        host 128-1 {hardware ethernet 1E:F8:2D:6E:2F:FF;fixed-address 2x.x.x.80;}
    
            }
    }
    

    Working example. We are using in our Proxmox Servers.

  • hostfavhostfav Member, Host Rep
    edited August 2018

    We are using to assign IP statically to a MAC address.

    You can use range:

          subnet 2x.x.x.216 netmask 255.255.255.248 {
                option subnet-mask 255.255.255.248;
                option broadcast-address 2x.x.x.223;
                option routers 2x.x.x.217;
                option domain-name-servers 8.8.8.8, 8.8.4.4;
                range  2x.x.x.218 2x.x.x.222;
                }
    
  • @Corey said:

    I could have multiple ip ranges assigned to an interface on my router, so how does it get decided what gateway these requests come from? Does it just come from the 'first' assigned ip range?

    The bootp/dhcp request is being processed by the relay agent on your router before it reaches your DHCP server. If you configure the relay agent on your router, it will listen for the BOOTP/DHCP host UDP broadcast requests on its interfaces. The agent will examine certain fields such as hop count and in particular the 'giaddr' field. If 'giaddr' is blank - that denotes that it is the first hop. The relay agent will fill the blank 'giaddr' out with the IP address with the IP address of the interface on which the BOOT/DHCP request was received on before the agent relays the request. That way if there are multiple hops before the BOOTP/DHCP server is reached, the 'giaddr' will contain the correct IP to return the response.

    When your DHCP server processes the request, the 'giaddr' field will examined so that the correct DHCP scope is used. Similarly, the 'giaddr' field is used by the relay agent to determine which interface to relay the BOOTREPLY or DHCPOFFER message which is generated by you DHCP server.

    Thanked by 1Corey
  • CoreyCorey Member
    edited August 2018

    @hostfav your response was completely irrelevant. I have a working setup. Was just wondering how the bootp relay was doing it's magic.
    @birchbeer Thank you for your explanation. It looks like from your response yes my router does use the first ip range assigned to the interface to send the traffic over to the bootp relay for the giaddr field.
    @dragon2611 thank you for your response, but I'm doing intervlan routing with a bootp relay for all interfaces.

  • dragon2611dragon2611 Member
    edited August 2018

    @Corey said:
    @hostfav your response was completely irrelevant. I have a working setup. Was just wondering how the bootp relay was doing it's magic.
    @birchbeer Thank you for your explanation. It looks like from your response yes my router does use the first ip range assigned to the interface to send the traffic over to the bootp relay for the giaddr field.
    @dragon2611 thank you for your response, but I'm doing intervlan routing with a bootp relay for all interfaces.

    That should be fine, my question was more about what would happen if the device running the relay had multiple IP addresses on the same Vlan interface, as some devices do support that.

  • birchbeerbirchbeer Member
    edited August 2018

    @dragon2611 said:
    That should be fine, my question was more about what would happen if the device running the relay had multiple IP addresses on the same Vlan interface, as some devices do support that.

    I am guessing you are asking about multiple IP address on a layer3 switch interface, you are basically making that a trunk. When a bootp request is generated by the client, the relay agent on the same VLAN as the client would fill out the giaddr before forwarding it. If that request is sent through a switch trunk, the relay agent on the switch would ignore the non-zero giaddr field and simply forward the bootp request on the other interfaces.

    But if you are asking about the unusual use-case where the client is on a VLAN with multiple subnets, I actually don't know what would happen. I skimmed through the RFC and I didn't see a specification for that use-case but I may have missed it.

  • @birchbeer said:

    @dragon2611 said:
    That should be fine, my question was more about what would happen if the device running the relay had multiple IP addresses on the same Vlan interface, as some devices do support that.

    But if you are asking about the unusual use-case where the client is on a VLAN with multiple subnets, I actually don't know what would happen. I skimmed through the RFC and I didn't see a specification for that use-case but I may have missed it.

    Yes this is the interesting one.

  • @birchbeer said:

    @dragon2611 said:
    That should be fine, my question was more about what would happen if the device running the relay had multiple IP addresses on the same Vlan interface, as some devices do support that.

    I am guessing you are asking about multiple IP address on a layer3 switch interface, you are basically making that a trunk. When a bootp request is generated by the client, the relay agent on the same VLAN as the client would fill out the giaddr before forwarding it. If that request is sent through a switch trunk, the relay agent on the switch would ignore the non-zero giaddr field and simply forward the bootp request on the other interfaces.

    But if you are asking about the unusual use-case where the client is on a VLAN with multiple subnets, I actually don't know what would happen. I skimmed through the RFC and I didn't see a specification for that use-case but I may have missed it.

    Yeah I'm doing the 'unusual use-case' and it looks like it's using the first assigned subnet.

  • It's theoretically possible for a client to use a "preferred IP" when doing a bootp request but I think that's typically used for IP renewals.

    I was imagining that there is possibly even a scenario where a relay agent could rebroadcast multiple requests with the giaddr for each interface. And in that case, the client could just pick a preferred request or whatever the first one that arrives - the RFC says it's up to the client - which sounds pretty random to me.

    In some switches like Cisco - if there are multiple gateways, I think that those gateways are considered secondary interfaces so I bet their relay agent would always use the primary gateway.

    Interesting use-case though.

  • @birchbeer said:
    It's theoretically possible for a client to use a "preferred IP" when doing a bootp request but I think that's typically used for IP renewals.

    I was imagining that there is possibly even a scenario where a relay agent could rebroadcast multiple requests with the giaddr for each interface. And in that case, the client could just pick a preferred request or whatever the first one that arrives - the RFC says it's up to the client - which sounds pretty random to me.

    In some switches like Cisco - if there are multiple gateways, I think that those gateways are considered secondary interfaces so I bet their relay agent would always use the primary gateway.

    Interesting use-case though.

    Yeah there aren't multiple nics on these machines so I had to make it all work with a single nic :)

Sign In or Register to comment.