https://docs.fedoraproject.org/en-US/Fedora/15/html/Deployment_Guide/sect-Configuring_a_Multihomed_DHCP_Server.html
/etc/sysconfig/dhcpd
and
/etc/dhcp/dhcpd.conf
files.
/etc/sysconfig/dhcpd
file to specify which network interfaces the DHCP daemon listens on. The following
/etc/sysconfig/dhcpd
example specifies that the DHCP daemon listens on the
eth0
and
eth1
interfaces:
DHCPDARGS="eth0 eth1";
eth0
,
eth1
, and
eth2
-- and it is only desired that the DHCP daemon listens on
eth0
, then only specify
eth0
in
/etc/sysconfig/dhcpd
:
DHCPDARGS="eth0";
/etc/dhcp/dhcpd.conf
file, for a server that has two network interfaces,
eth0
in a 10.0.0.0/24 network, and
eth1
in a 172.16.0.0/24 network. Multiple
subnet
declarations allow different settings to be defined for multiple networks:
default-lease-time600
; max-lease-time7200
; subnet 10.0.0.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; option routers 10.0.0.1; range 10.0.0.5 10.0.0.15; } subnet 172.16.0.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; option routers 172.16.0.1; range 172.16.0.5 172.16.0.15; }
subnet 10.0.0.0
netmask 255.255.255.0
;
subnet
declaration is required for every network your DHCP server is serving. Multiple subnets require multiple
subnet
declarations. If the DHCP server does not have a network interface in a range of a
subnet
declaration, the DHCP server does not serve that network.
subnet
declaration, and no network interfaces are in the range of that subnet, the DHCP daemon fails to start, and an error such as the following is logged to
/var/log/messages
:
dhcpd: No subnet declaration for eth0 (0.0.0.0). dhcpd: ** Ignoring requests on eth0. If this is not what dhcpd: you want, please write a subnet declaration dhcpd: in your dhcpd.conf file for the network segment dhcpd: to which interface eth1 is attached. ** dhcpd: dhcpd: dhcpd: Not configured to listen on any interfaces!
option subnet-mask 255.255.255.0
;
option subnet-mask
option defines a subnet mask, and overrides the
netmask
value in the
subnet
declaration. In simple cases, the subnet and netmask values are the same.
option routers 10.0.0.1
;
option routers
option defines the default gateway for the subnet. This is required for systems to reach internal networks on a different subnet, as well as external networks.
range 10.0.0.5
10.0.0.15
;
range
option specifies the pool of available IP addresses. Systems are assigned an address from the range of specified IP addresses.
dhcpd.conf(5)
man page.
/etc/dhcp/dhcpd.conf
, the DHCP daemon fails to start.
/etc/sysconfig/dhcpd
and
/etc/dhcp/dhcpd.conf
files.
/etc/dhcp/dhcpd.conf
example creates two subnets, and configures an IP address for the same system, depending on which network it connects to:
default-lease-time600
; max-lease-time7200
; subnet 10.0.0.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; option routers 10.0.0.1; range 10.0.0.5 10.0.0.15; } subnet 172.16.0.0 netmask 255.255.255.0 { option subnet-mask 255.255.255.0; option routers 172.16.0.1; range 172.16.0.5 172.16.0.15; } host example0 { hardware ethernet 00:1A:6B:6A:2E:0B; fixed-address 10.0.0.20; } host example1 { hardware ethernet 00:1A:6B:6A:2E:0B; fixed-address 172.16.0.20; }
host example0
host
declaration defines specific parameters for a single system, such as an IP address. To configure specific parameters for multiple hosts, use multiple
host
declarations.
host
declarations, and as such, this name can anything, as long as it is unique to other
host
declarations. To configure the same system for multiple networks, use a different name for each
host
declaration, otherwise the DHCP daemon fails to start. Systems are identified by the
hardware ethernet
option, not the name in the
host
declaration.
hardware ethernet 00:1A:6B:6A:2E:0B
;
hardware ethernet
option identifies the system. To find this address, run the
ip link
command.
fixed-address 10.0.0.20
;
fixed-address
option assigns a valid IP address to the system specified by the
hardware ethernet
option. This address must be outside the IP address pool specified with the
range
option.
option
statements do not end with a semicolon, the DHCP daemon fails to start, and an error such as the following is logged to
/var/log/messages
:
/etc/dhcp/dhcpd.conf line 20: semicolon expected. dhcpd: } dhcpd: ^ dhcpd: /etc/dhcp/dhcpd.conf line 38: unexpected end of file dhcpd: dhcpd: ^ dhcpd: Configuration file errors encountered -- exiting
host
declarations configure a single system, that has multiple network interfaces, so that each interface receives the same IP address. This configuration will not work if both network interfaces are connected to the same network at the same time:
host interface0 { hardware ethernet 00:1a:6b:6a:2e:0b; fixed-address 10.0.0.18; } host interface1 { hardware ethernet 00:1A:6B:6A:27:3A; fixed-address 10.0.0.18; }
interface0
is the first network interface, and
interface1
is the second interface. The different
hardware ethernet
options identify each interface.
host
declarations, remembering to:
fixed-address
for the network the host is connecting to.
host
declaration unique.
host
declaration is not unique, the DHCP daemon fails to start, and an error such as the following is logged to
/var/log/messages
:
dhcpd: /etc/dhcp/dhcpd.conf line 31: host interface0: already exists dhcpd: } dhcpd: ^ dhcpd: Configuration file errors encountered -- exiting
host interface0
declarations defined in
/etc/dhcp/dhcpd.conf
.