DHCP Setup

On the clients

Installation

 # apt-get install dhcp-client

Configuration

To actually use the DHCP client on the client machine you have to configure the network interface card (NIC) in /etc/network/interfaces like this:

auto eth0
iface eth0 inet dhcp

Maybe you want to replace eth0 with the device name of the NIC your machine uses but normally, eth0 for the first NIC should work.

On the server

Installation

 # apt-get install dhcp3-server

Configuration

Edit /etc/dhcpd3/dhcpd.conf to look like this:

 # Simple DHCP server config
ddns-update-style none;

# option definitions common to all supported networks... option domain-name cafe.whatever.org; option domain-name-servers ns.cafe.whatever.org; option routers router.cafe.whatever.org;

# Most leases are static anyway. default-lease-time 72000; max-lease-time 72000;

# If this DHCP server is the official DHCP server for the local # network, the authoritative directive should be uncommented. authoritative;

# Use this to send dhcp log messages to a different log file (you also # have to hack syslog.conf to complete the redirection). log-facility local7;

# We use the following policy: # # Fixed server addresses in the range 1 - 9 # Dynamic client addresses in the range 10 - 99 # Fixed client addresses in range 100 -

subnet 192.168.0.0 netmask 255.255.255.0 { range 192.168.0.10 192.168.0.99; }

For each single host that should get a static IP address, make a copy of the following snippet and append it to the config:

host merkur {
  hardware ethernet 00:00:00:00:00:00;
  fixed-address merkur.cafe.whatever.org;
}

Change the host name (in this case merkur) and the MAC address in the line hardware ethernet to suit your needs. For this config to work, the DHCP server has to resolve the domain names somehow. Putting them into /etc/hosts will work. A better solution is to use a name server for network wide name resolution. This subject is covered in another Howto.

You can find out the MAC address of a given NIC in multiple ways:

  1. Type ifconfig in your shell and find the MAC address in the entry of the NIC in question.
  2. Have a look at the log file of your DHCP server after a client booted. The client will present the server its MAC address and ask for an IP address. The MAC address is logged, too.

At the end, make sure the DHCP server is actually running:

 # /etc/init.d/dhcp3-server restart