What do DHCP Lease Time and Domain Name do?
Why do we need to set a lease time to a DHCP server? What happens to a client who uses that IP address while it was expired? If i set its time to 100 years, what difference does it make?
Also, i don't know why we have to set a domain name to a DHCP server. What's the idea behind it?
Solution 1:
IP addresses are resources in TCP/IP networking, and they need to be managed. You can do that manually (setting all computers to static IP addresses) or you can use a DHCP server that does the management for you, based on the rules as described in RFC1531.
When a client asks for an IP address, and the DHCP server is about to "lease" the address to the client, the server has to know how long this lease should be. If leases were of indefinite length, then as soon as all IP addresses have been leased, you could not connect any new clients, even if the computers using the previously leased addresses had all stopped working. If leases were of length zero, there would be no point having them.
If a lease expires, then the server sees this a sign that this IP address can now be re-used, i.e. assigned to a different client. Should a computer use the address without the knowledge of the DHCP server, then you can end up with two computers using the same address, which would create chaos on your network (since both computers would be answering the same queries simultaneously, and these two could not talk to each other, as they would be effectively just talking to themselves).
Setting the default lease time (or any lease time for a particular lease) to 100 years makes this IP address (or any addresses leased with that time) unavailable for 100 years. As TomTom already said, this would for all intents and purposes disable the benefits of having DHCP.
Your last question doesn't make much sense, since it lacks clarity of detail. There are several options in a DHCP server that deal with DNS:
- When the DHCP server is instructed to hand out fixed IP addresses for particular clients, a DDNS hostname can be defined. This allows the DHCP server to dynamically update an identified DNS server, so that name resolution is provided for that client.
- If the client is configured to provide a hostname to the DHCP server, then dynamic DNS updates can take place using that hostname
- DHCP servers do not only provide IP addresses, they can provide a whole range of configuration options to the client (DHCP stands for Dynamic Host Configuration Protocol). One of these options is to tell the client which DNS servers to use for name resolutions. If you do not configure this option, then each client has to be configured manually for DNS resolution (which sort of defeats the idea of DHCP).
- If none of the above answer your question, then please clarify what exactly the question was.
Solution 2:
Why do we need to set a lease time to a DHCP server?
The lease time is setup so that a client doesn't hold an IP address indefinitely. It allows for a mechanism to gracefully reuse DHCP addresses.
What happens to a client who uses that IP address while it was expired?
When DCHP is working correctly the client will start trying to renew the lease at the half life of the lease. This is to prevent the IP address from being assigned to another machine and provide a graceful way to keep the lease. The reservation is there to give clients more stable addresses - for example in most companies on weekends most computers are turned off, so on Monday dhcp gives out the SAME address again.
If i set its time to 100 years, what difference does it make?
Noone ever gets the address. The client, even when off, will have the client reserved for 100 years and as a result you will run out of addresses. If you put the lease too high, you successfully prevent address reuse.
Also, i don't know why we have to set a domain name to a DHCP server. What's the idea behind it?
The idea is that the client knows which domain it is in, when you you type "blabla" into the web browser the computer can also try "blabla.domain.company" because it knows the domain name. Same setting like in the tcp/ip settings (default domain suffix).