Handing out IPs: DHCP
From Debian Clusters
The DHCP server is responsible for handing out dynamic IPs to all the machines on the network who don't have static IPs explicitly set. This allows much easier configuration of IP addresses - rather than having to go in and edit the IPs on different machines, all the settings for IP addresses are in one location.
The machine that will act as the DHCP server needs to have new packages installed and configured. The DHCP clients only need to be set to receive IP addresses dynamically (see below).
DHCP Tips
Determining Eth Names
To determine which port corresponds to eth0 or eth1, plug an Ethernet cable into one of the ports but not both, then run
mii-tool
You'll be able to tell which interface that port belongs to based on which one is negotiating a link. If you'd like to change which is which, or give them completely new names, see Udev: Renaming Network Interfaces.
Setting a Dynamic IP
Setting a machine to receive a dynamic IP is easy. Unless you specifically specified this when you first installed Debian (and most people don't), then it's already set up for you. In /etc/network/interfaces, a dynamic IP set up by the Debian installer looks like this:
# The primary network interface auto eth0 iface eth0 inet dhcp
The important part here is the dhcp (versus static). In this example, eth0 will send a DHCP request out to the network. The response from a DHCP server includes what eth0 should set its IP address to, the netmask, the default gateway (router), and any domain name servers. Of course, this means that you need to have a DHCP server set up to do this!
Setting a Static IP
Generally, the only machine in a cluster that should have a static IP is possibly the outside interface of the firewall, and the DHCP server. Setting up a static IP requires editing two flies: /etc/network/interfaces again, and /etc/resolv.conf. Because a machine with a static IP won't contact a DHCP server, it needs much more background information about the world.
/etc/network/interfaces
Instead of using dhcp like a machine with a dynamic IP does, static needs to be specified in /etc/network/interfaces, and then the address, netmask, and gateway all need to be specified. In my setup, my firewall needs to have a static IP on its outside interface (eth0), which looks like this:
# The primary network interface
auto eth0
iface eth0 inet static
address X.X.X.X
gateway X.X.X.X
netmask 255.255.128.0
-
addressis the IP address it should have. -
netmaskis the netmask for this network -
gatewayis the router it uses to talk to the outside Internet
Because it acts as a DHCP server on the internal interface (eth1), it also has a static IP address there. Notice this time that it doesn't have a gateway specified - that's because it already has a gateway specified in the above statements and doesn't need another (it will route through it's own eth0 to eth0's default gateway).
# The secondary network interface (goes to the switch)
auto eth1
iface eth1 inet static
address 192.168.1.254
netmask 255.255.255.0
/etc/resolv.conf
Machines with static IP addresses also need to be told who their nameservers are, since they won't receive that information from their DHCP server. (This is another reason why it's nice to have dynamic IPs - if your nameserver changes and your entire cluster used static IPs, you'd have to change this file for every machine.) This is specified in /etc/resolv.conf with
nameserver X.X.X.X
where X.X.X.X is the IP address of the nameserver. Multiple nameservers can be specified on multiple lines.

