pfsense-mac-to-dns-mapper/README.md

31 lines
1.6 KiB
Markdown

# 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 `ssh`ing on the local network
## Requirements
pfSense with:
- the [pfsense-api](https://github.com/jaredhendrickson13/pfsense-api) installed
- existing DHCP servers configured with domain names or subdomains matching the SAN+domain combinations
### Examples
#### Create
```shell
$ 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)
```shell
$ 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
```