DHCP custom configuration - (when|will) it be available?



  • Please advise when it will be possible to add a custom configuration to DHCPD config file? I'm integrating pfSense DHCPD with The Foreman / Katello for hosts provisioning and figured out my "hackish" way to do that but I don't like. Any forecasts?
    Thank you!



  • @CapitanBlack said in DHCP custom configuration - (when|will) it be available?:

    custom configuration to DHCPD config file?

    You are using pfSense so you can use a GUI to setup the needed services.
    pfSense will create, and recreate, the needed config file.
    These config files are not read back in again to see if there are user edits. They are overwritten on the fly when the process needs to start.

    Can you explain what are your needs ?

    Not this :

    78eaa5b6-e103-42ab-8c02-546b98c73693-image.png

    ?



  • I am integrating The Foreman/Katello (www.theforeman.org) with pfSense for automated VM's provisioning. I need to enable OMAPI by adding below config lines to DHCPD config file. So far I did it via a script (see below). The cron script itself works fine - I'm currently testing if Foreman-pfSense provisioning works as it should...
    P.S. I will also need OMAPI key for the official BIND daemon running on pfSense. Thanks!

    omapi-port 7911;
    key omapi_key {
        algorithm HMAC-MD5;
        secret "==OMAPI-SECRET==";
    };
    omapi-key omapi_key;
    

    DHCPD custom configuration watchdog

    #!/bin/sh
    # === /root/bin/dhcpd_custom_config_watchdog ===
    #
    
    # Adds custom config to the end of DHCP config file if it was not found.
    # Custom DHCP config saved in '/var/dhcpd/etc/dhcpd.conf.omapi' file.
    #
    
    if ! grep -q omapi /var/dhcpd/etc/dhcpd.conf ; then
    
    # Restart DHCPD to ensure it has the latest configuration
    pfSsh.php playback restartdhcpd
    
    echo "Save DHCPD command line..."
    echo `ps axww | grep '[/]usr/local/sbin/dhcpd' | tr -s '[:blank:]' | grep -o '\/usr\/local\/sbin\/dhcpd.*'` > /var/tmp/dhcpd_cmdline
    killall dhcpd
    
    echo "Backing up DHCPD configuration file to '/var/dhcpd/etc/dhcpd.conf.bak'..."
    cp -f /var/dhcpd/etc/dhcpd.conf /var/dhcpd/etc/dhcpd.conf.bak
    echo "Applying custom configuration..."
    cat /var/dhcpd/etc/dhcpd.conf.omapi >> /var/dhcpd/etc/dhcpd.conf
    
    # Restart DHCPD with the original comand line...
    eval $(cat /var/tmp/dhcpd_cmdline)
    
    fi
    # === /root/bin/dhcpd_custom_config_watchdog ===
    

    Then install 'cron' package and add below line

    574886dc-6ca4-43f4-a184-0c1cd517bad6-image.png

    Below screenshot explains how The Foreman uses ISC DHCPD and BIND for VM's provisioning.

    be0ce791-48ee-4b27-b5ad-4b53c4252d38-image.png


  • Rebel Alliance Developer Netgate

    There is an option to enable OMAPI coming in 2.5.0: https://redmine.pfsense.org/issues/7304

    You might be able to adapt the diff on the issue to apply to 2.4.4



  • @jimp - thanks a lot! I (and many other Foreman enthusiast) need it for sure!

    Can you please provide instruction on how to make and apply the diff?



  • NVM, figured it out...



  • d5e9f07d-7d6a-484e-84a6-bdf62f3bde4d-image.png

    ae6c0dbb-2aae-4b73-bc51-be97eb11929b-image.png



  • Tested three most recent patches starting from 2577004fa21a13c6f00427e96334b051de5ab1a2 - all gives various patching errors...

    My pfSense is 2.4.4-RELEASE-p3 (amd64)



  • Try against the latest "2.4.5 pre release" that became available very recently.


  • Rebel Alliance Developer Netgate

    I do not expect that to apply cleanly, which is why I said you'd need to adapt it. Look at what changed, and make similar changes to your system by hand.

    That said, it does apply cleanly to the 2.4.5 tree so it may be worth trying there.



  • Yes, thanks guys - I've deployed a new virtual firewall to try the patch.
    Will post here...


Log in to reply