3

I have a dhcpd.conf that looks like this. How do I listen on interface enp2s0?

#
# DHCP Server Configuration file.
#   see /usr/share/doc/dhcp*/dhcpd.conf.example
#   see dhcpd.conf(5) man page

subnet 192.168.10.0 netmask 255.255.255.0 {
    authoritative;
    range 192.168.10.10 192.168.10.100;
    }
anon says hello
  • 133
  • 1
  • 2
  • 10

2 Answers2

4

On Red Hat 8 and derivatives, you now don't have to do anything, except configure your interfaces and your dhcpd.conf correctly:

[root@foo ~]# cat /etc/sysconfig/dhcpd 
# 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.
...

If you check /var/log/messages, you'll see that:

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

So this should Just Work (TM), but points are awarded for worrying about running a DHCP server on the wrong interface. ;)

bolind
  • 512
  • 3
  • 15
2

dhcpd man page shows:

COMMAND LINE

The names of the network interfaces on which dhcpd should listen for broadcasts may be specified on the command line. This should be done on systems where dhcpd is unable to identify non-broadcast interfaces, but should not be required on other systems. If no interface names are specified on the command line dhcpd will identify all network interfaces which are up, eliminating non-broadcast interfaces if possible, and listen for DHCP broadcasts on each interface.

On Debian, interfaces on which dhcpd listens must be specified in /etc/default/isc-dhcp-server (ref):

INTERFACES="enp2s0"

On RedHat, it seems to be in /etc/sysconfig/dhcpd (ref):

DHCPDARGS="enp2s0";
logypock
  • 39
  • 4