{"id":29555020,"url":"https://github.com/jftuga/pfsense_dhcp_static","last_synced_at":"2025-10-09T22:37:25.953Z","repository":{"id":276721608,"uuid":"930080121","full_name":"jftuga/pfsense_dhcp_static","owner":"jftuga","description":"Scripts to manage static DHCP entries on pfSense using CSV files","archived":false,"fork":false,"pushed_at":"2025-03-07T04:45:10.000Z","size":17,"stargazers_count":4,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-08-10T23:47:44.649Z","etag":null,"topics":["command-line","csv","csv-files","dhcp","dhcp-server","pfsense","pfsense-firewall","php-script"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/jftuga.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-02-10T03:08:20.000Z","updated_at":"2025-04-06T12:30:26.000Z","dependencies_parsed_at":"2025-08-10T23:38:12.366Z","dependency_job_id":null,"html_url":"https://github.com/jftuga/pfsense_dhcp_static","commit_stats":null,"previous_names":["jftuga/pfsense_dhcp_static"],"tags_count":1,"template":false,"template_full_name":null,"purl":"pkg:github/jftuga/pfsense_dhcp_static","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jftuga%2Fpfsense_dhcp_static","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jftuga%2Fpfsense_dhcp_static/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jftuga%2Fpfsense_dhcp_static/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jftuga%2Fpfsense_dhcp_static/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jftuga","download_url":"https://codeload.github.com/jftuga/pfsense_dhcp_static/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jftuga%2Fpfsense_dhcp_static/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":279002104,"owners_count":26083307,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-10-09T02:00:07.460Z","response_time":59,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["command-line","csv","csv-files","dhcp","dhcp-server","pfsense","pfsense-firewall","php-script"],"created_at":"2025-07-18T08:37:52.254Z","updated_at":"2025-10-09T22:37:25.935Z","avatar_url":"https://github.com/jftuga.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# pfSense DHCP Static Mapping Scripts\n\n## Overview\nThese scripts are designed to manage static DHCP mappings on a pfSense firewall running **pfSense 2.7.2 CE**.\n\n- `add_dhcp_static.php`: Adds new DHCP static assignments from a CSV file.\n- `export_dhcp_static.php`: Exports existing DHCP static assignments to a CSV file.\n- `remove_dhcp_static.php`: Removes specific static DHCP assignments based on IP, MAC, or hostname.\n- `remove_all_dhcp_static.php`: Removes all static DHCP assignments from all interfaces.\n\n## Prerequisites\n- These scripts must be run **directly on the pfSense firewall**.\n- Requires root access (`ssh` or console access).\n- Basic understanding of pfSense DHCP configurations.\n\n---\n\n## `add_dhcp_static.php`\n\n### Description\n* This script reads a CSV file containing DHCP static assignments and adds them to the pfSense DHCP server.\n* It is capable of **properly adding** static entries into different DHCP interface scopes.\n* * This can be useful when moving a group of DHCP static assignments from one VLAN to another as this can't easily be done from the Web GUI.\n* When using the `--allow` switch, you can override the limitation within the Web GUI which does not allow you to create a static assignment within the reservation pool.\n* * **WARNING:** Be aware that you will not be able to then edit this entry from within the Web GUI as it doesn't allow for static entries inside the reservation scope.\n\n### CSV Format\nThe CSV file should have the following header and format:\n```\nmac,ipaddr,hostname,description\n00:11:22:33:44:55,192.168.1.100,device1,Test Device\nAA:BB:CC:DD:EE:FF,192.168.1.101,device2,Another Test Device\n```\n\n### Handling Duplicates\nBefore adding a new entry, the script checks if:\n- The **IP address** already has a static assignment.\n- The **MAC address** is already assigned.\n- The **hostname** is already in use.\n\nIf any of these exist, the script will **skip** the entry to prevent conflicts.\n\n### Usage\n```sh\nphp /root/add_dhcp_static.php /path/to/input.csv\n```\n\n---\n\n## `export_dhcp_static.php`\n\n### Description\nThis script exports all existing DHCP static assignments, including those on VLANs, to a CSV format.\n\n### Output Format\nThe script prints output in the following format:\n```\nmac,ipaddr,hostname,description\n00:11:22:33:44:55,192.168.1.100,device1,Test Device\nAA:BB:CC:DD:EE:FF,192.168.1.101,device2,Another Test Device\n```\n\n### Usage\nTo export DHCP reservations and save them to a file:\n```sh\nphp /root/export_dhcp_static.php \u003e dhcp_static_reservations.csv\n```\nTo display directly in the terminal:\n```sh\nphp /root/export_dhcp_static.php\n```\n\n---\n\n## `remove_dhcp_static.php`\n\n### Description\nThis script removes specific static DHCP assignments based on IP address, MAC address, or hostname.\n\n### Usage\n```sh\nphp /root/remove_dhcp_static.php \u003cIP/MAC/Hostname\u003e [\u003cIP/MAC/Hostname\u003e ...]\n```\n\n**Example:**\n```sh\nphp /root/remove_dhcp_static.php 192.168.1.100 00:11:22:33:44:55 device1\n```\n\n**Expected Output:**\n```\nRemoved static DHCP reservation for MAC 00:11:22:33:44:55\nRemoved static DHCP reservation for IP 192.168.1.100\nRemoved static DHCP reservation for hostname device1\nChanges applied.\n```\n\n---\n\n## `remove_all_dhcp_static.php`\n\n### Description\nThis script removes **all** static DHCP assignments from all interfaces on the pfSense firewall and applies the changes.\n\n### Usage\n```sh\nphp /root/remove_all_dhcp_static.php\n```\n\n**Expected Output:**\n```\nRemoved all static DHCP reservations from interface: lan\nRemoved all static DHCP reservations from interface: vlan10\nRemoved all static DHCP reservations from interface: vlan20\nAll static DHCP reservations have been removed and changes applied.\n```\n\n---\n\n## Example Demo\n### Adding DHCP Reservations\n```sh\nphp /root/add_dhcp_static.php new_reservations.csv\n```\n**Expected Output:**\n```\nProcessing CSV file: new_reservations.csv\nSkipping: MAC 00:11:22:33:44:55 already assigned\nAdded: 192.168.1.102 for MAC FF:EE:DD:CC:BB:AA\nApplying changes...\nDone.\n```\n\n### Exporting DHCP Reservations\n```sh\nphp /root/export_dhcp_static.php \u003e dhcp_backup.csv\n```\n**Expected Output (inside `dhcp_backup.csv`):**\n```\nmac,ipaddr,hostname,description\n00:11:22:33:44:55,192.168.1.100,device1,Test Device\nAA:BB:CC:DD:EE:FF,192.168.1.101,device2,Another Test Device\n```\n\n### Removing Specific DHCP Reservations\n```sh\nphp /root/remove_dhcp_static.php 192.168.1.100 00:11:22:33:44:55 device1\n```\n**Expected Output:**\n```\nRemoved static DHCP reservation for MAC 00:11:22:33:44:55\nRemoved static DHCP reservation for IP 192.168.1.100\nRemoved static DHCP reservation for hostname device1\nChanges applied.\n```\n\n### Removing All DHCP Reservations\n```sh\nphp /root/remove_all_dhcp_static.php\n```\n**Expected Output:**\n```\nRemoved all static DHCP reservations from interface: lan\nRemoved all static DHCP reservations from interface: vlan10\nRemoved all static DHCP reservations from interface: vlan20\nAll static DHCP reservations have been removed and changes applied.\n```\n\n---\n\n## Notes\n- These scripts modify the **pfSense configuration**, so always **backup your settings** before running them.\n- After making changes with `add_dhcp_static.php`, `remove_dhcp_static.php`, or `remove_all_dhcp_static.php`, you may need to restart the DHCP service for them to take effect.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjftuga%2Fpfsense_dhcp_static","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjftuga%2Fpfsense_dhcp_static","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjftuga%2Fpfsense_dhcp_static/lists"}