2012년 5월 6일 일요일

DHCP Servers with Multiple NICs

DHCP servers with multiple interfaces pose two configuration challenges. The first is setting up the correct routing and the second is making sure only the required interfaces are listening to serve DHCP. Don’t worry, both will be discussed next.

Routing

When a DHCP configured PC boots, it requests its IP address from the DHCP server. It does this by sending a standardized DHCP broadcast request packet to the DHCP server with a source IP address of 255.255.255.255.
If your DHCP server has more than one interface, you have to add a route for this 255.255.255.255 address so that it knows the interface on which to send the reply; if not, it sends it to the default gateway. (In both of the next two examples, we assume that DHCP requests will be coming in on interface eth0).
Note: More information on adding Linux routes and routing may be found in Chapter 3, "Linux Networking".
Note: You can't run your DHCP sever on multiple interfaces because you can only have one route to network 255.255.255.255. If you try to do it, you'll discover that DHCP serving working on only one interface.

Temporary Solution

You can temporarily add a route to 255.255.255.255 using the route add command as seen below.
[root@bigboy tmp]# route add -host 255.255.255.255 dev eth0
If you want this routing state to be maintained after a reboot, then use the permanent solution that's discussed next.

Permanent Solution

Create a permanent route to 255.255.255.255. This will vary according to your version of Linux
Fedora / RedHat / CentOS: Add the route to your /etc/sysconfig/network-scripts/route-eth0 file if the route needs to be added to your eth0 interface.
#
# File /etc/sysconfig/network-scripts/route-eth0
#

255.255.255.255/32 dev eth0
Ubuntu / Debian: Add the route to your /etc/network/interfaces file. In this case the route is added to the eth0 interface.
#
# File: /etc/network/interfaces
#

iface eth0 inet static

       up route add -host 255.255.255.255 eth0
Simple Linux routing is covered in Chapter 3, "Linux Networking" and will add more clarity to adding permanent static routes.

Listening

Once you have defined the interface for your DHCP routing you should also ensure that your DHCP server only listens on that interface and no others. This methodology to do this varies depending on your versión of Linux.
Fedora / RedHat / CentOS: The /etc/sysconfig/dhcpd file must be edited and the DHCPDARGS variable edited to include the preferred interface. In this example interface eth0 is preferred.
# File: /etc/sysconfig/dhcpd
DHCPDARGS=eth1
Debian / Ubuntu: The /etc/default/dhcp3-server file must be edited and the INTERFACES variable edited to include the preferred interface. In this example interface eth0 is preferred.
# File: /etc/default/dhcp3-server
INTERFACES="eth0"
You will be able to verify success in one of two ways. First the netstat command using the –au options will give the list of interfaces listening on the bootp (DHCP) UDP port.
[root@bigboy-f ~]# netstat -au  | grep bootp
udp        0     0 192.168.1.100:bootps    *:*
[root@bigboy-f ~]#
Secondly, your /var/log/messages file will also reveal the defined interfaces used when the DHCPd daemon was restarted.
Jan  8 17:22:44 bigboy dhcpd: Listening on LPF/eth0/00:e0:18:5c:d8:41/192.168.1.0/24
Jan  8 17:22:44 bigboy dhcpd: Sending on   LPF/eth0/00:e0:18:5c:d8:41/192.168.1.0/24
Success! You can go back to lunch!

댓글 없음:

댓글 쓰기