Project

General

Profile

Actions

Bug #3404

open

DHCP Server Fails to Start on Interfaces that are Slow to Come Online During Boot

Added by Jason Crowley about 10 years ago. Updated about 10 years ago.

Status:
New
Priority:
Normal
Assignee:
-
Category:
DHCP (IPv4)
Target version:
-
Start date:
01/22/2014
Due date:
% Done:

50%

Estimated time:
Plus Target Version:
Release Notes:
Affected Version:
All
Affected Architecture:
All

Description

When the services_dhcpd_configure() function is called during boot, it will skip interfaces that are not fully online. If all dhcpd-enabled interfaces are not online, dhcpd will fail to start. If only some of the interfaces are online, it will start but not serve dhcp on the slow-to-start interfaces.

The place where we've been able to reproduce this consistently is OpenVPN interfaces that have dhcpd enabled.

Background Information

OpenVPN's native IP-address allocation system does not work with dnsmasq to register clients' IP addresses in DNS. To work around this limitation, we build an OpenVPN tunnel that allows us to obtain IP addresses from pfSense's DHCP server. The dhcpd instance will then go through the normal process to ensure that the client's IP is registered with dnsmasq.

Platform Affected

2.1-RELEASE We're using amd64, but I expect it affects all processor architectures.

Steps to Reproduce

  1. Configure an OpenVPN Server in tap mode. Ensure you've set the following parameters.
    • Device Mode: tap
    • IPv4 Tunnel Network: <blank>
      • We want dhcpd, not openvpn assigning IP addresses.
    • Advanced configuration: server-bridge
      • This enables the DHCP broadcast traffic to traverse the tunnel to the dhcpd instance on the pfSense OpenVPN interface
  2. Configure the OpenVPN interface with a static IP address.
  3. Configure and enable a DHCP server on the OpenVPN interface.
  4. Reboot.
  5. Log in via SSH and execute the following command.
    # ps -axww | grep dhcpd
    ...
    46118  ??  Ss     0:00.09 /usr/local/sbin/dhcpd -user dhcpd -group _dhcp -chroot /var/dhcpd -cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid em0 em2
    
  6. Note that the last two arguments in the dhcpd command line above are the interfaces for dhcpd to listen on. There is not an OpenVPN interface (ovpns1) there. If you try to acquire a DHCP lease over an OpenVPN connection, you will get no response.
  7. Restart dhcpd via the web gui Services page.
    # ps -axww | grep dhcpd
    ...
    69734  ??  Ss     0:00.00 /usr/local/sbin/dhcpd -user dhcpd -group _dhcp -chroot /var/dhcpd -cf /etc/dhcpd.conf -pf /var/run/dhcpd.pid em0 em2 ovpns1
    
  8. Note that the ovpns1 interface is now in the command line. You can now acquire a DHCP lease through your OpenVPN tunnel.

Recommended Solution

One of my coworkers (Micah Mitchell) is working on a simple solution that will add about 10 lines of code to the services_dhcpd_configure() function. This code will check each interface configured with a DHCP server to see that it is up before starting dhcpd. If an interface is not up, it will sleep for 1 second and loop for up to 10 seconds before moving on.

Our initial testing shows this code resolves the problem on the pfSense instances we've tested it on. During boot, we see a two-second delay while services_dhcpd_configure() waits for interfaces to come online prior to launching dhcpd. Expect the code to be submitted within the next day or two.


Files

services.inc.patch (945 Bytes) services.inc.patch Micah Mitchell, 01/22/2014 12:43 PM
openvpn.inc.patch (981 Bytes) openvpn.inc.patch Jason Crowley, 01/24/2014 08:07 AM
Actions

Also available in: Atom PDF