Using a DHCP Client


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

graphics/note.gif

If you want your computer to function as a DHCP server so that it can deliver IP addresses to other systems, consult Chapter 5, Configuring Other Computers via DHCP. You'll need to configure the DHCP server with a static IP address.


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.

graphics/02fig01.gif

Unfortunately, DHCP configuration isn't always quite this easy. Potential problems include the following:

  • Incompatible DHCP clients ” Four DHCP clients are common on Linux systems: pump , dhclient , dhcpxd , and dhcpcd (don't confuse either of the latter two with dhcpd , the DHCP server). Although all four work properly on many networks, some networks use DHCP servers that don't get along well with one or another Linux DHCP clients. You might therefore need to replace your DHCP client package with another one.

  • Incompatible DHCP options ” DHCP client options sometimes cause problems. In practice, this situation can be difficult to distinguish from an incompatible DHCP client, but the solution is less radical : You can edit the DHCP startup script to change its options. Unfortunately, you'll need to learn enough about your DHCP client to have some idea of what options to edit. Reading the man page may give you some ideas.

  • Multi-NIC configurations ” If your computer has two or more network interface cards (NICs), you may need to get the DHCP client to obtain an IP address for only some cards, or to disregard some information (such as the gateway address, described in more detail shortly in "Adjusting the Routing Table") for some NICs. Again, editing the DHCP client startup script may be necessary, or you may need to create a custom script to correct an automatic configuration after the fact.

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
Distribution Default DHCP Client Alternative DHCP Clients DHCP Client Startup Script Extra Configuration Files
Caldera OpenLinux Server 3.1 dhclient none /etc/sysconfig/network-scripts/ifup-dhcp etc/sysconfig/network , //etc/sysconfig/ network-scripts/ifcfg-eth0 , /etc/dhcp/dhclient.conf
Debian GNU/Linux 2.2 pump dhcpcd /sbin/ifup (binary file) /etc/network/interfaces
Linux Mandrake 8.1 dhcpcd dhclient , dhcpxd /sbin/ifup /etc/sysconfig/network , /etc/sysconfig/network-scripts/ifcfg-eth0
Red Hat Linux 7.2 pump dhcpcd /sbin/ifup /etc/sysconfig/network , /etc/sysconfig/network-scripts/ifcfg-eth0
Slackware Linux 8.0 dhcpcd none /etc/rc.d/rc.inet1 none
SuSE Linux 7.3 dhcpcd dhclient /etc/init.d/dhclient /etc/rc.config
TurboLinux 7 dhclient none /sbin/ifup /etc/sysconfig/network , /etc/sysconfig/network-scripts/ifcfg-eth0

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.



Advanced Linux Networking
Advanced Linux Networking
ISBN: 0201774232
EAN: 2147483647
Year: 2002
Pages: 203

Similar book on Amazon

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