Okay, you've got a specific set of requirements: local DDNS for .office.internal, optional upstream resolution via dns.usc.edu, lightweight, easy configuration, and no DHCP or CoreDNS. This narrows down the options considerably.
The Best Choice: bind9 (Berkeley Internet Name Domain)
While bind9 has a reputation for being complex, it's incredibly powerful and can be configured relatively simply for your use case. It's a very mature and stable DNS server. It does have a learning curve, but it's manageable for a small, static setup like yours. Crucially, it supports DDNS and doesn't require DHCP.
Why bind9 over other options?
- DDNS Support:
bind9 has built-in support for dynamic updates, which is what you need for DDNS.
- Flexibility: You can configure it to serve only the
.office.internal zone and forward other requests to dns.usc.edu.
- Stability: It's a well-tested and reliable DNS server.
- Lightweight (relatively): While not as lightweight as dnsmasq, it's not a resource hog, especially for a small number of workstations.
- No DHCP Dependency: You explicitly don't want DHCP, and
bind9 doesn't require it.
Configuration Steps (Ubuntu/Debian Example - Adapt for your OS)
These instructions are for a Debian/Ubuntu system. Adjust package names and paths as needed for your distribution. I'll break it down into sections.
1. Installation:
sudo apt update
sudo apt install bind9 bind9utils bind9-doc
2. Configure named.conf.options:
This file controls global options. Edit /etc/bind/named.conf.options:
options {
directory "/var/cache/bind";
forwarders {
dns.usc.edu;
};
dnssec-validation auto;
listen-on-v6 { none; }; // Disable IPv6 listening if not needed
};
directory: Specifies the working directory for bind9.
forwarders: This is key. It tells bind9 to forward any queries it can't resolve locally to dns.usc.edu. If you don't want upstream resolution, remove this section.
dnssec-validation: Enables DNSSEC validation. Generally a good idea.
listen-on-v6: Disables IPv6 listening if you're not using IPv6. This can simplify things.
3. Create a Zone File for .office.internal:
Create a new zone file, for example, /etc/bind/db.office.internal:
;
; BIND data file for office.internal
;
$TTL 604800
@ IN SOA ns1.office.internal. admin.office.internal. (
2024010101 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS ns1.office.internal.
ns1 IN A 192.168.1.10 ; Replace with your server's IP
;
; Workstation entries (example)
workstation1 IN A 192.168.1.20
workstation2 IN A 192.168.1.30
;
$TTL: Time-to-live for records.
SOA: Start of Authority record. Replace ns1.office.internal. and admin.office.internal. with appropriate values. The serial number (2024010101) must be incremented whenever you make changes to the zone file. The format is YYYYMMDDNN.
NS: Name Server record. Points to your DNS server.
A: Address record. Maps a hostname to an IP address. Add entries for each workstation. Replace the IP addresses with the actual IPs.
4. Configure named.conf.local:
Edit /etc/bind/named.conf.local to define the zone:
zone "office.internal" {
type master;
file "/etc/bind/db.office.internal";
allow-update { key "ddns-key"; }; // Allow dynamic updates with the key
};
zone: Defines the zone.
type master: This server is the primary authority for this zone.
file: Specifies the path to the zone file.
allow-update: This is critical for DDNS. It allows dynamic updates to the zone, but only from clients using the specified key.
5. Create a DDNS Key:
Generate a HMAC-SHA256 key for secure dynamic updates:
sudo dnssec-keygen -a HMAC-SHA256 -b 256 -n HOST ddns-key
This will create two files: Kddns-key.+163+<keyid>.key and Kddns-key.+163+<keyid>.private. The <keyid> will be a number.
6. Add the Key to named.conf.local:
Add the key information to named.conf.local:
key "ddns-key" {
algorithm hmac-sha256;
secret "<the base64 encoded secret from the .private file>";
};
Open the .private file (e.g., Kddns-key.+163+12345.private) and copy the Secret: line. Paste that base64 encoded string into the secret field in named.conf.local. Be careful to copy the entire string correctly.
7. Configure Workstations for DDNS:
On each workstation, you'll need a DDNS client. nsupdate is a common choice. Here's a basic example script (adapt for your OS and shell):
#!/bin/bash
HOST="workstation1" # Replace with the workstation's hostname
ZONE="office.internal"
SERVER="192.168.1.10" # Replace with your bind9 server's IP
KEYFILE="/path/to/Kddns-key.+163+<keyid>.key" # Replace with the path to the key file
IP=$(ip addr show | grep -Po 'inet \K[\d.]+') # Get the workstation's IP address
nsupdate -k "$KEYFILE" <<EOF
server $SERVER
zone $ZONE
update delete $HOST A
update add $HOST 60 A $IP
send
EOF
- Replace the placeholders with the correct values.
- This script deletes any existing A record for the workstation and adds a new one with the current IP address.
- You'll need to make this script executable (
chmod +x script.sh) and run it periodically (e.g., using cron) to keep the DNS records up-to-date.
8. Restart bind9:
sudo systemctl restart bind9
9. Test:
- From a workstation on your network, try to ping
workstation1.office.internal.
- From a workstation on your network, try to resolve a domain outside of
.office.internal (e.g., google.com). It should be resolved by dns.usc.edu.
- Check the
bind9 logs (/var/log/syslog or /var/log/messages) for any errors.
Important Considerations:
- Security: The DDNS key is sensitive. Protect it carefully. Restrict access to the key file.
- Firewall: Make sure your firewall allows DNS traffic (port 53) to your
bind9 server.
- Serial Number: Always increment the serial number in the zone file whenever you make changes. Otherwise, clients may not pick up the updates.
- Key Management: Consider rotating the DDNS key periodically for security.
- Error Handling: Add error handling to your DDNS client script to ensure it's working correctly.
- IP Address Changes: The script assumes the IP address is obtained from
ip addr show. Adjust this if your system uses a different method.
This is a comprehensive guide. It will take some effort to set up, but it provides a robust and flexible solution for your DDNS requirements. Remember to adapt the configuration to your specific environment. Good luck!