Questo contenuto non è disponibile nella lingua selezionata.
14.4. Configuring a Multihomed DHCP Server
DHCP server serves multiple networks, that is, multiple subnets. The examples in these sections detail how to configure a DHCP server to serve multiple networks, select which network interfaces to listen on, and how to define network settings for systems that move networks.
/etc/dhcp/dhcpd.conf file.
DHCP daemon will only listen on interfaces for which it finds a subnet declaration in the /etc/dhcp/dhcpd.conf file.
/etc/dhcp/dhcpd.conf file, for a server that has two network interfaces, enp1s0 in a 10.0.0.0/24 network, and enp2s0 in a 172.16.0.0/24 network. Multiple subnet declarations allow you to define different settings for multiple networks:
-
subnet 10.0.0.0 netmask 255.255.255.0; - A
subnetdeclaration is required for every network yourDHCPserver is serving. Multiple subnets require multiplesubnetdeclarations. If theDHCPserver does not have a network interface in a range of asubnetdeclaration, theDHCPserver does not serve that network.If there is only onesubnetdeclaration, and no network interfaces are in the range of that subnet, theDHCPdaemon fails to start, and an error such as the following is logged to/var/log/messages:Copy to Clipboard Copied! Toggle word wrap Toggle overflow -
option subnet-mask 255.255.255.0; - The
option subnet-maskoption defines a subnet mask, and overrides thenetmaskvalue in thesubnetdeclaration. In simple cases, the subnet and netmask values are the same. -
option routers 10.0.0.1; - The
option routersoption 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; - The
rangeoption specifies the pool of availableIPaddresses. Systems are assigned an address from the range of specifiedIPaddresses.
dhcpd.conf(5) man page.
Warning
14.4.1. Host Configuration Copia collegamentoCollegamento copiato negli appunti!
/etc/sysconfig/dhcpd and /etc/dhcp/dhcpd.conf files.
The following /etc/dhcp/dhcpd.conf example creates two subnets, and configures an IP address for the same system, depending on which network it connects to:
-
host example0 - The
hostdeclaration defines specific parameters for a single system, such as anIPaddress. To configure specific parameters for multiple hosts, use multiplehostdeclarations.MostDHCPclients ignore the name inhostdeclarations, and as such, this name can be anything, as long as it is unique to otherhostdeclarations. To configure the same system for multiple networks, use a different name for eachhostdeclaration, otherwise theDHCPdaemon fails to start. Systems are identified by thehardware ethernetoption, not the name in thehostdeclaration. -
hardware ethernet 00:1A:6B:6A:2E:0B; - The
hardware ethernetoption identifies the system. To find this address, run theip linkcommand. -
fixed-address 10.0.0.20; - The
fixed-addressoption assigns a validIPaddress to the system specified by thehardware ethernetoption. This address must be outside theIPaddress pool specified with therangeoption.
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:
The following host declarations configure a single system, which 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:
interface0 is the first network interface, and interface1 is the second interface. The different hardware ethernet options identify each interface.
host declarations, remembering to:
- assign a valid
fixed-addressfor the network the host is connecting to. - make the name in the
hostdeclaration 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
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.