3 The configuration file
Next, you need to edit the configuration file “/etc/dhcp3/dhcpd.conf”.
- option domain-name "example.org";
This sets the domain name. Unless you have a DNS server under your control or you have extensive definitions
in /etc/hosts, it does not matter. This is a topic reserved for a module designated to DNS servers. For now,
you can set it to test.org just to see the effects.
- option domain-name-servers ns1.example.org;
This is important. This sets the DNS server that will be sent to DHCP clients. You can also use an IP address,
such as 10.0.2.3.
- default-lease-time 600;
This means a lease has a 10 minute (600 seconds) period.
- max-lease-time 7200;
If a DHCP client requests a specific lease time, this is the maximum that the DHCP server will grant (in
seconds).
- authoritative;
Uncomment this line if a DHCP server is the only one in the network!
- log-facility local7;
Now, let us consider some thing that we can do with the rest of this file:
subnet 10.0.2.0 netmask 255.255.255.0 {
}
This configures the subnet to only use static IP address. Although we can simply turn of the DHCP server, this makes it
possible to switch back to use a DHCP server.
Now, let us consider a more common setting:
subnet 10.0.2.0 netmask 255.255.255.0 {
option broadcast-address 10.0.2.255;
option routers 10.0.2.2;
range 10.0.2.32 10.0.2.63;
}
This configures the DHCP to assign addresses from 10.0.2.32 to 10.0.2.63. It also configures 10.0.2.2 as the gateway
(called routers in this context). 10.0.2.255 is the broadcast address, but that’s to be expected with the subnet and netmask
configuration.
host 10.0.2.25 {
hardware ethernet 52:54:00:12:34:59;
fixed-address 10.0.2.25;
}
This configures that if a NIC with the MAC address of 52:54:00:12:34:50 asks for an IP address, it will be
10.0.2.25.
Once you are done editing the configuration file, you have to restart the DHCP server using
“/etc/init.d/dhcp3-server restart”.