No description
Find a file
2024-04-27 11:50:36 -05:00
.envrc.example initial commit 2024-01-08 20:50:47 -06:00
.gitignore initial commit 2024-01-08 20:50:47 -06:00
.renovaterc.json5 fix: consistency w/ homelab, remove workflow, fix error messages, error handling 2024-04-27 11:50:36 -05:00
LICENSE.md fix: consistency w/ homelab, remove workflow, fix error messages, error handling 2024-04-27 11:50:36 -05:00
map-all.sh fix: consistency w/ homelab, remove workflow, fix error messages, error handling 2024-04-27 11:50:36 -05:00
pfsense-mapping.sh fix: consistency w/ homelab, remove workflow, fix error messages, error handling 2024-04-27 11:50:36 -05:00
README.md fix: consistency w/ homelab, remove workflow, fix error messages, error handling 2024-04-27 11:50:36 -05:00

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