How DHCP Works


DHCP eliminates the need for you to manually configure your system's TCP/IP information, and instead fetches that information from a central server. A program called dhclient allows FreeBSD to act as a DHCP client. When a system configured to use DHCP boots and dhclient starts, it sends out broadcast requests on UDP port 68, looking for any server on the LAN that will respond with DHCP information. Because these datagrams are sent to the broadcast address (255.255.255.255), it doesn't matter that the client machine doesn't have any TCP/IP information configured yet.

If there is a DHCP server on the network, it listens on port 68 for these requests. When it receives a request for configuration information, it checks its database for a free IP address that can be assigned to the client. It then sends back (again to the broadcast address, because the client doesn't have an IP address yet) an "offer" containing the selected IP address. After some negotiation, all of which takes place on the broadcast address and thus is visible to all computers on the network, the DHCP server sends the client (on UDP port 67) all the TCP/IP configuration information that you would otherwise have had to set manually. The IP address that is assigned to the client is removed from the pool of available addresses so that it is not assigned to another client that requests DHCP configuration information.

The host that is running dhclient applies the agreed-upon TCP/IP configuration, and from then on can use the routed IP network using the assigned IP address and other settings.

IP Address Leases

When the DHCP server assigns an IP address to a client, the client does not "own" the address on any permanent basis. Rather, the address is leased, for a term that is configured on the DHCP server. The information about how long the lease is good for is sent to the client along with the configuration information.

The leasing of IP addresses serves two purposes:

  • If the DHCP server cannot be contacted, the client checks its database to look for a lease that is still valid. Assuming it has a valid lease, the client can continue to function normally, even if the DHCP server is currently down, though its configuration will eventually time out and become invalid.

  • It automatically places IP addresses that are not in use back in the pool after the lease expires. This helps conserve IP addresses. For example, when a guest from a branch office visits, he can plug his laptop into your network and be assigned an IP address so that he can use your network. When he leaves, that IP address will eventually expire and be placed back into the pool for others to use. This way, IP addresses are not being wasted on systems that do not exist anymore.

Advantages of DHCP over Static IP Addresses

Depending on your situation, DHCP may have several advantages over simply assigning each system its own static IP addresses. These advantages include the following:

  • Ease of maintenance. DHCP automatically keeps track of which IP addresses are in use and which ones are free. This prevents the system administrator from having to manually update a list of which IP addresses can be assigned to new clients, as well as having to remember to reclaim old IP addresses when clients are permanently removed from the network. All this is handled automatically with DHCP.

  • Ease of installing new clients. When new clients are installed, you (or the user) do not have to worry about setting up the network information. You can simply ask the new client to obtain its information via DHCP, and all the networking information will be configured automatically.

  • Ease of use for travelers. If your users travel to branch offices, DHCP makes their life a lot easier. With DHCP, they can simply plug their laptops into the network at the branch office and have all the network information configured for them automatically. At the next branch office they go to, they can do the same thing and get a new set of valid information. This way, your users do not have to reconfigure their network settings at each office they visit.

  • It conserves IP addresses. This is especially true if you have traveling users who go to branch offices occasionally and plug their laptops into the network. DHCP allows these IP addresses to be automatically reclaimed after the traveling user leaves. This way, you don't have IP addresses wasted on systems that are rarely plugged into the network anyway.

  • It eliminates problems caused by IP address conflicts. It only takes one user to make one typing mistake when setting up a system to cause all kinds of problems on a network. The user might enter an IP address that conflicts with another system on the network, for example, or an address that conflicts with the IP address assigned to a server. DHCP eliminates these problems by assigning IP addresses automatically and keeping track of ones that are in use so that they do not get assigned to multiple systems.

DHCP has become an integral part of any well-maintained corporate network and critical to the accepted best practices of network management. Even home network users will find DHCP to be indispensable, even if they don't know it existsit means they no longer have to worry about typing in esoteric TCP/IP information themselves, whether they're dialing up directly to an ISP or attaching themselves to a wireless home network. Indeed, DHCP has been one of the cornerstones of the proliferation of home broadband Internet in recent years, and without it millions of people would find the experience more technical than they were comfortable with.

The only time when it is not appropriate to use DHCP is when you're running a server. Machines with assigned DNS names, and machines that provide services such as NFS shares and web and email, have to have static IP addresses so that client machines can reliably contact them. For this reason, a common corporate network topology is one where the internal network is based on DHCP, so that the hundreds or even thousands of employees, whose IP addresses aren't important, can all receive dynamic TCP/IP information within the corporate network; but the company's official web server is located on the DMZ network with a static IP address and a public DNS name so that it can be reached from anywhere on the planet at any time.

Note

The reason why many broadband service providers don't allow customers to run servers has not only to do with the limited upload speed of the cable or ADSL connection, but with the fact that assigning customers dynamic IP addresses through DHCP is far more economical than reserving static IP addresses for the thousands or tens of thousands of customers on the network.





FreeBSD 6 Unleashed
FreeBSD 6 Unleashed
ISBN: 0672328755
EAN: 2147483647
Year: 2006
Pages: 355
Authors: Brian Tiemann

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net