1.6 KiB
1.6 KiB
pfSense MAC-to-DNS-Mapper
Given an input of ./pfsense-mapping.sh <INTERFACE MAC ADDRESS> <SHORT HOSTNAME> ...<SAN> it will create multiple entries in pfSense to aid in Homelab Infrastructure as Code tasks.
It will create:
- a static DHCP entry with the lowest available IP on a specific interface (with instllation specific subdomain mappings) so the VM/LXC always comes back with the same IP
- a split DNS entry in unbound pointing at the same IPs as above with both the FQDN and all additional SANs for easy ACME Certificates and easy
sshing on the local network
Requirements
pfSense with:
- the pfsense-api installed
- existing DHCP servers configured with domain names or subdomains matching the SAN+domain combinations
Examples
Create
$ LOG_LEVEL=info ./pfsense-mapping.sh 00:AA:BB:CC:DD:EE example example.subdomain
[INFO] pfSense MAC Address to Domain Mapper
[INFO] attempting to create static DHCP mapping for example.subdomain.auengun.net -> 10.0.20.23
[INFO] Missing FQDN unbound DNS record creating DNS mapping for example.auengun.net -> 10.0.20.23
[INFO] Success
Update (and add new subdomain)
$ LOG_LEVEL=info ./pfsense-mapping.sh 00:AA:BB:CC:DD:EE example example.subdomain example.subdomain-2
[INFO] pfSense MAC Address to Domain Mapper
[INFO] Existing static DHCP mapping for example.subdomain.auengun.net -> 10.0.20.101
[INFO] attempting to create static DHCP mapping for example.subdomain-2.auengun.net -> 10.0.30.101
[INFO] Existing FQDN unbound DNS record found, trying to update record 42
[INFO] Success