[SOLVED] Delete all static mapping for interface



  • Hi,
    We had created more than 500 static mapping for our dhcp pool. Now we need to remove all static mapping & need to reconfigure again. Is there any solution for this instead of removing one by one @ dhcp configuration page ?

    Regards
    Sreyas


  • Rebel Alliance Developer Netgate

    Is that your only DHCP-enabled interface?

    If so, you can wipe the DHCP config from the command prompt using:

    pfSsh.php playback disabledhcpd
    

    That will completely remove ALL DHCP server configuration from the firewall for ALL interfaces.

    If you need to keep some settings, then your safest bet is to backup the config, edit out the settings you do not want, and then restore the backup.

    There are other ways using PHP commands and unsetting specific variables, but they are not as reliable.



  • No, I have 2 LAN interfaces

    1. Enabled DHCP for office users  - LAN#1
    2. Enabled DHCP with captive portal for guest users - LAN#2

    My task is to remove some range of static mapping from LAN#1 interface [if not possible I need to delete all static mapping]

    If I remove all static entries is there any way to  export a range of static entries / is it possible to edit dhcp table


  • Rebel Alliance Developer Netgate

    Not effectively.

    The closest you'll get is to backup config.xml (actually make two copies, just in case the edited one breaks), then you can copy/paste the mappings you want to keep in a new XML file and remove them from the config.xml backup copy. Then restore that config.xml.



  • Could you please let me know exact location for config file & where can I find dhcp related details on that file.


  • Rebel Alliance Developer Netgate

    Diagnostics > Backup/Restore - download a backup from there. If you restore a backup (even an edited one), use the same page.

    In that file, the DHCP settings are under <pfsense>… <dhcpd>... <[interface name]> and the individual mappings are under <staticmap>tags. Once you look at the file it's fairly obvious.</staticmap></dhcpd></pfsense>



  • @jimp
    Thank you for sharing this, it will help, even with my home network as I have many static assigned devices.

    @sreyas
    Yes trying to do this one by one is very trying and time consuming - bordering on near impossible.

    After jimp had said where the files were and their format I went and looked and realized that maybe an XML editor would be helpful, so I went and found a free opensource one at sourceforge;

    XML Copy Editor 1.2.1.3

    https://sourceforge.net/projects/xml-copy-editor/?source=directory

    there is both a Linux (in .deb format) and Windows (in install .exe format) version.

    I've just tried the Linux version and it works.

    Most important though is to have made two or three good backups on preferably different media of the pfSense config. Then only edit one and reload and test it.

    Take Care & Enjoy



  • @Jimp
    Thank You for your guidance, it works perfect & this is what I exactly needed.

    @DGordon

    Thank you  for sharing your experience, the download link helps me a lot. I had deleted all my stale entries & restored the config file. Now my box is back to normal without any issues,

    Take care & Have an nice day. ;)