Dynamic Addresses

 < Day Day Up > 



Your DHCP server can be configured to select IP addresses from a given range and assign them to different clients. Given a situation where you have many clients that may not always be connected to the network, you could effectively service them with a smaller pool of IP addresses. IP addresses are assigned only when they are needed. With the range declaration, you specify a range of addresses that can be dynamically allocated to clients. The declaration takes two arguments, the first and last addresses in the range.

range 192.168.1.5 192.168.1.128;

For example, if you are setting up your own small home network, you would use a network address beginning with 192.168. The range would specify possible IP addresses with that network. So for a network with the address 192.168.0.0, you would place a range declaration along with any other information you want to give to your client hosts. In the following example, a range of IP addresses beginning from 192.168.0.1 to 192.168.0.128 can be allocated to the hosts on that network:

range 192.168.0.5 192.168.0.128;

You should also define your lease times, both a default and a maximum:

default-lease-time 21600; max-lease-time 43200;

For a small, simple home network, you just need to list the range declaration along with any global options as shown here. If your DHCP server is managing several subnetworks, you will have to use the subnet declarations.

In order to assign dynamic addresses to a network, the DHCP server will require that your network topology be mapped. This means it needs to know what network addresses belong to a given network. Even if you use only one network, you will need to specify the address space for it. You define a network with the subnet declaration. Within this subnet declaration, you can specify any parameters, declarations, or options to use for that network. The subnet declaration informs the DHCP server of the possible IP addresses encompassed by a given subnet. This is determined by the network IP address and the netmask for that network. The next example defines a local network with address space from 192.168.0.0 to 192.168.0.255. The range declaration allows addresses to be allocated from 192.168.0.5 to 192.168.0.128.

subnet 192.168.1.0 netmask 255.255.255.0 {           range 192.168.0.5 192.168.0.128;  }

Versions of DHCP prior to 3.0 required that you even map connected network interfaces that are not being served by DHCP. Thus each network interface would have to have a corresponding subnet declaration. Those not being serviced by DHCP would have a not authoritative parameter as shown here (192.168.2.0 being a network not to be serviced by DHCP). In version 3.0 and later, DHCP simply ignores unmapped network interfaces:

subnet 192.168.2.0 netmask 255.255.255.0 {  not authoritative; }

The implementation of a very simple DHCP server for dynamic addresses is shown in the sample dhcpd.conf file that follows.

/etc/dhcpd.conf

start example
 option routers 192.168.0.1;  option subnet-mask 255.255.255.0;  option domain-name "mytrek.com ";  option domain-name-servers 192.168.0.1;     subnet 192.168.1.0 netmask 255.255.255.0 {      range 192.168.0.5 192.168.0.128;      default-lease-time 21600;      max-lease-time 43200;      } 
end example



 < Day Day Up > 



Red Hat(c) The Complete Reference
Red Hat Enterprise Linux & Fedora Edition (DVD): The Complete Reference
ISBN: 0072230754
EAN: 2147483647
Year: 2004
Pages: 328

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