DHCP



  • Can someone help me with these? I need to find how exactly DHCP works on a network. I'm finding difficulty with this topic cause I'm not a network person. Thanks in advance. 🙂



  • Like Hammer, let's break it down:

    1. The client sends out a discover request. In IPv4 this means sending to 255.255.255.255 (broadcast) over UDP. In IPv6 this is called solicit request. Sending packets to that IP means that the network equipment will broadcast to all hosts it can.
    2. The server response with an offer in IPv4, or advertisement in IPv6, they both contain the initial IP information for the client to use.
    3. The client responds in both IPv4 and IPv6 with a broadcast requesting the IP issued in #2.
    4. The servers says "that's cool, bro" and then it's all good to go.

    In both IPv4 and IPv6 the machines have an initial self-assigned IP address (link-local), and that's what they use to make the requests and get the responses. These work differently for both protocols. You'll probably notice with IPv4 it'll be an IP address like 169.254.0.0/16, depending on the stack and configuration. In IPv6 the self-assigned address is based upon your MAC address, and often with the advertisement mentioned above, it'll respond with almost the same address, just the "prefix" will be different. In other words your link-local address in IPv6 will start in fe80::/10, but the first half of that will change to something else in most cases.

    DHCP and BOOTP work almost in the exact same way, so since you're not a network guy, you can gladly think of them as essentially the same thing. There are also proprietary or modified versions of DHCP which some networks use (like ISPs).

    I hope that makes sense.



  • Thank you @tonyshowoff .

    Is this works the same with LAN and WAN?

    According to my researches, there is a thing called LEASE. It's like a permission or a contract to me but can you please explain more what it is?



  • @XeL said in DHCP:

    Thank you @tonyshowoff .

    Is this works the same with LAN and WAN?

    It can and often does, but for certain types of networks like Cable or DSL, it may work differently, though we don't think of those as WANs. More often the assignment works slightly differently, but the spirit of it is basically the same. In a regular WAN, for a private network, or whatever it does often work the same.

    According to my researches, there is a thing called LEASE. It's like a permission or a contract to me but can you please explain more what it is?

    Lease is typically just another term for the exchange I mentioned above, but it can also refer to the amount of time the IP address is associated with that machine, which you can call a contract. This is done for two primary reasons:

    1. The client itself may not always be connected, but this way it can (usually, but it depends on the client) obtain the same IP when it comes back if its within the lease time
    2. Related to the above, if a client disappears that IP will be held until the lease is up then it will be re-assigned. This solves the issue of running out of IP addresses in case someone comes back.

    So in this manner the lease time is a contract between client and server, they both know that the IP is only available to that client until the expire time.



  • @tonyshowoff -- That is the most excellent explanation of DHCP I've ever seen... It's totally not my fault if that shows up on random geeky websites across the internet!



  • Your device will attempt to renew your lease at the 50% mark of what you set your timeout to. So if it's 7 days, in 3.5 days it's going to try to renew. Then if it doesn't renew it will be 50% of that, so on and so forth until it drops the lease completely. So if you have a ton of devices going in and out of a place it makes sense to set the lease time lower so you don't run out of IP addresses.



  • DHCP is a single protocol and works the same way no matter where it is used. However you can't use DHCP "over" a WAN, it is non-routable. So at best you can get a DHCP lease from a local router that you are connected to.



  • @scottalanmiller said in DHCP:

    DHCP is a single protocol and works the same way no matter where it is used. However you can't use DHCP "over" a WAN, it is non-routable. So at best you can get a DHCP lease from a local router that you are connected to.

    Not straight up traditional DHCP, no, but with certain router configurations (in my experience with Cisco's broadcast forwarding, for example) you can indeed do this. Is it a smart idea? Probably not for all kinds of reasons. Additionally as I said some things like cable transceivers work in some sort of oddly similar fashion, not like hooking up to a regular switch à la Moscow city-LAN or something.

    But I was trying to keep it all simple for the non-network guy 😉



  • @tonyshowoff said in DHCP:

    @scottalanmiller said in DHCP:

    DHCP is a single protocol and works the same way no matter where it is used. However you can't use DHCP "over" a WAN, it is non-routable. So at best you can get a DHCP lease from a local router that you are connected to.

    Not straight up traditional DHCP, no, but with certain router configurations (in my experience with Cisco's broadcast forwarding, for example) you can indeed do this. Is it a smart idea? Probably not for all kinds of reasons. Additionally as I said some things like cable transceivers work in some sort of oddly similar fashion, not like hooking up to a regular switch à la Moscow city-LAN or something.

    Still non-routable, being forwarded is an agent that is retransmitting.



  • @scottalanmiller said in DHCP:

    @tonyshowoff said in DHCP:

    @scottalanmiller said in DHCP:

    DHCP is a single protocol and works the same way no matter where it is used. However you can't use DHCP "over" a WAN, it is non-routable. So at best you can get a DHCP lease from a local router that you are connected to.

    Not straight up traditional DHCP, no, but with certain router configurations (in my experience with Cisco's broadcast forwarding, for example) you can indeed do this. Is it a smart idea? Probably not for all kinds of reasons. Additionally as I said some things like cable transceivers work in some sort of oddly similar fashion, not like hooking up to a regular switch à la Moscow city-LAN or something.

    Still non-routable, being forwarded is an agent that is retransmitting.

    Yes, that's true, but from the perspective of a non-networking guy with just wanting a basic understanding of what works then I can't imagine there'd be much of a difference. I imagine any situation where one tried to do it without the specialty knowledge, they'd give up and just setup another DHCP server locally.



  • Thanks all of you.. This discussion really is a big help. 🙇



  • Glad that it helped 🙂


Log in to reply