If your local network has a DHCP server, you can configure Linux to obtain its IP address from this server automatically, by using a DHCP client. This client sends a broadcast message on its local network segment to search for a DHCP server. If a DHCP server responds, and if the ensuing negotiation is successful, the result should be a system with an IP address and associated information, fully configured to use the connection. NOTE
Most Linux distributions give you the option of using DHCP during installation. You should be able to select a DHCP option when configuring the network settings. If not, or if you need to reconfigure the computer after installation, the easiest way to enable this feature is usually to use a GUI configuration tool, such as Linuxconf (Red Hat or Mandrake), COAS (Caldera), or YaST or YaST2 (SuSE). For instance, Figure 2.1 shows the YaST2 configuration screen in which this option is set. Click Automatic Address Setup (via DHCP), and the system will obtain its IP address via DHCP. Figure 2.1. GUI configuration tools make it easy to enable DHCP client operation.
Unfortunately, DHCP configuration isn't always quite this easy. Potential problems include the following:
To help you make adjustments, Table 2.1 presents the default DHCP client package, alternative DHCP client packages, locations of DHCP startup scripts, and locations of closely related configuration files for each of several popular Linux distributions. (Debian's ifup tool, unlike similarly named tools in other distributions, is a binary program with the DHCP client package commands hard-coded, which can make modifying those commands tricky. Some limited control can be exerted through the /etc/network/ interfaces configuration file.) Even if your distribution doesn't officially support your preferred DHCP client, you can install and use it. At worst, you'll need to modify the DHCP client startup script specified in Table 2.1, or create a custom DHCP client startup procedure by modifying some startup script (precisely what script you might modify is partly dependent on your distribution and partly a matter of personal preference). Table 2.1. DHCP Client Information for Seven Popular Linux Distributions
If you suspect you're encountering problems because of DHCP client options that don't get along well with those of your network's DHCP server, you can try editing the DHCP startup script listed in Table 2.1. Look for the line that calls the DHCP client program and examine its options, using the man page for the DHCP client program for reference. You may need to add or remove options to get the behavior you need. For instance, some DHCP servers require that the client send a hostname, so you may need to add an option like -h hostname for dhcpcd . Sometimes these scripts rely on values set in other configuration files, as listed in the Extra Configuration Files column of Table 2.1. More frequently, though, these files tell the system whether to use a static IP address or DHCP. |