4

I have a machine running Centos 7 with 8 network interfaces. I have three of those interfaces configured and running.

I have configured dhcpd to handle the local lan interfaces.

I get the following warnings in syslog for the un-configured interfaces:

No subnet declaration for enp6s0 (no IPv4 addresses).
** Ignoring requests on enp6s0.  If this is not what
you want, please write a subnet declaration
in your dhcpd.conf file for the network segment
to which interface enp6s0 is attached. **

In the past I would have edited /etc/syslog/dhcpd to indicate which interfaces to listen on. But that file now says to not do that and specify a subnet for the interfaces.

These unused interfaces do not have addresses so I don't see how I can write a subnet configuration for them.

Is there an alternate way to have dhcpd ignore these interfaces?

First Edit -

Doing this to existing subnet declarations makes the warnings go away:

subnet xx.xx.xx.xx mask yy.yy.yy.yy {

    interface zzzzzz;

    .... subnet declaration

}

But, I can find zero documentation that shows an interface option for subnet. I consider that odd.

6 Answers 6

3

I believe /etc/sysconfig/dhcpd indicates how to limit the interfaces listened on on systemd on a ${RHELish}7 system:

cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system
sed -i '/^ExecStart/s/$/ blah0 blah1 .../' /etc/systemd/system/dhcpd.service
systemctl --system daemon-reload
systemctl restart dhcpd.service
1
  • Yes it does. I will probably mark this as the correct answer even though it feels really dirty copying and editing up the service files instead of a simple config file. Sep 18, 2015 at 19:31
3

You don't need to add the interface line if it is on a different subnet. The Slackware 14.2 Linux distribution provides the following example:

# No service will be given on this subnet, but declaring it helps the
# DHCP server to understand the network topology.

subnet 192.168.2.0 netmask 255.255.255.0 {
}

When this is added to dhcpd.conf, you'll see messages like the following logged:

Listening on LPF/wlan0/a0:2b:6a:b5:24:d0/192.168.2.0/24
Sending on   LPF/wlan0/a0:2b:6a:b5:24:d0/192.168.2.0/24

But no service will be offered to that subnet.

Alternatively, if you are only serving DHCP over a single interface, you can specify that interface on the command line when you start dhcpd:

dhcpd eth0

This second method does not require you to specify any additional subnets in dhcpd.conf, and is particularly handy if you are serving DHCP to a physically isolated network.

1

Comments below found in /etc/sysconfig/dhcpd on CentOS 7.2:

# WARNING: This file is NOT used anymore.

# If you are here to restrict what interfaces should dhcpd listen on,
# be aware that dhcpd listens *only* on interfaces for which it finds subnet
# declaration in dhcpd.conf. It means that explicitly enumerating interfaces
# also on command line should not be required in most cases.
0

The solution is to tell dhcpd that it is not supposed to monitor those interfaces. By default dhcpd will try to monitor all broadcast-capable interfaces, but you can specify on the command-line an explicit list of interfaces to manage. Check the startup scripts for dhcpd and you will find a place where you can insert the specific ethN you want it to operate on.

Or you can ignore the warning. It's just telling you that you might not get what you expected due to potential misconfiguration. You've implicitly asked dhcpd to monitor all interfaces and it's letting you know it can't.

3
  • Yeah, that is how I would have done this in the past. But, Centos 7 & systemd seems to have some different thoughts on this. Oddly, adding an interface statement to the subnet configuration appears to have cleared things up. But, I can find no documentation that shows an interface option for the subnet declaration. Sep 18, 2015 at 18:02
  • Ah.. yeah, networkd. In that case ignore my answer, sorry.
    – caskey
    Sep 18, 2015 at 18:04
  • One option would be to use loopback segments for them 127.1.0.0/24 and 127.2.0.0/24, but that's a bit of a hack. It does look like you can use ".network" files with a [match] section for each mac address and then specify DHCPServer=no, but that's beyond my understanding. Good luck.
    – caskey
    Sep 18, 2015 at 18:08
0

RHEL6

set DHCPDARGS in /etc/sysconfig/dhcpd to include only those interfaces you want the daemon to listen on (eg eth0 eth1 ignoring eth3):

DHCPDARGS="eth0 eth1"

Restore DHCPDARGS functionality to RHEL7

# cp /usr/lib/systemd/system/dhcpd.service /etc/systemd/system/
# vi /etc/systemd/system/dhcpd.service
# ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid $DHCPDARGS
# systemctl --system daemon-reload
# systemctl restart dhcpd.service
0

The answer provided by Richard is correct for RHEL 7 as well.

I would have just added this as a comment to his answer, but I don't have sufficient reputation yet.

According to the documentation, the correct place for user modified systemd unit files to reside is /etc/systemd/system.

I can confirm that by placing the dhcpd.service file in /etc/systemd/system and modifying the ExecStart line in this file to include the desired interface(s) as he has shown in his answer works.

To expand a little on his answer:

After making the changes and starting the service, you can query it's status with:

systemctl status dhcpd.service

I get the following output confirming that it's listening on the correct interface, and only the one that I want.

systemctl status dhcpd.service

● dhcpd.service - DHCPv4 Server Daemon Loaded: loaded (/etc/systemd/system/dhcpd.service; disabled; vendor preset: disabled) Active: active (running) since Mon 2011-05-02 03:32:11 CDT; 5s ago Docs: man:dhcpd(8) man:dhcpd.conf(5) Main PID: 27814 (dhcpd) Status: "Dispatching packets..." CGroup: /system.slice/dhcpd.service └─27814 /usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid enp3s0

May 02 03:32:11 host.example dhcpd[27814]: Copyright 2004-2013 Internet Systems Consortium. May 02 03:32:11 host.example dhcpd[27814]: All rights reserved. May 02 03:32:11 host.example dhcpd[27814]: For info, please visit https://www.isc.org/software/dhcp/ May 02 03:32:11 host.example dhcpd[27814]: Wrote 0 deleted host decls to leases file. May 02 03:32:11 host.example dhcpd[27814]: Wrote 0 new dynamic host decls to leases file. May 02 03:32:11 host.example dhcpd[27814]: Wrote 0 leases to leases file. May 02 03:32:11 host.example dhcpd[27814]: Listening on LPF/enp3s0/00:1e:0b:50:f7:64/10.0.0.0/24 May 02 03:32:11 host.example dhcpd[27814]: Sending on
LPF/enp3s0/00:1e:0b:50:f7:64/10.0.0.0/24 May 02 03:32:11 host.example dhcpd[27814]: Sending on Socket/fallback/fallback-net May 02 03:32:11 host.example systemd[1]: Started DHCPv4 Server Daemon.

/etc/systemd/system/dhcpd.service

[Unit] Description=DHCPv4 Server Daemon
Documentation=man:dhcpd(8) man:dhcpd.conf(5) 
Wants=network-online.target After=network-online.target 
After=time-sync.target

[Service] 
Type=notify 
ExecStart=/usr/sbin/dhcpd -f -cf /etc/dhcp/dhcpd.conf -user dhcpd -group dhcpd --no-pid enp3s0

[Install] 
WantedBy=multi-user.target

Tested on RHEL 7.6 x86_64 with dhcp-4.2.5-68.el7

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .