Okay, let's explore some options for a lightweight, easy-to-configure DNS server that supports local Dynamic DNS updates without requiring DHCP, and that can forward requests for other domains.
Recommended Option: CoreDNS
CoreDNS is a very strong choice for this scenario. It's lightweight, highly configurable via plugins, and can easily forward requests to external resolvers. It also has a plugin specifically for dynamic updates.
Why CoreDNS is suitable:
- Lightweight and Fast: CoreDNS is written in Go and designed for performance and resource efficiency. It's significantly lighter than full-fledged BIND9.
- Dynamic Updates (RFC 2136): CoreDNS supports dynamic DNS updates out-of-the-box via the
dnstap and rfc2136 plugins.
- Flexible Configuration (Corefile): The
Corefile allows for granular control over DNS zones, forwarding, and other settings using a plugin architecture.
- Easy to Configure: The
Corefile is relatively simple to understand and edit.
- No DHCP Required: It works perfectly well with static IP addressing or a DHCP server that you're not controlling through CoreDNS.
- Forwarding: You can easily configure it to forward requests for domains not ending in
.office.internal to dns.usc.edu.
Installation:
-
Download and Install:
-
Go to the CoreDNS releases page: https://coredns.io/download/
-
Download the appropriate pre-compiled binary for your operating system and architecture (e.g., coredns_1.11.1_linux_amd64.tgz).
-
Extract the archive. You'll find a single executable file named coredns.
-
Place the coredns executable in a suitable location, such as /usr/local/bin/ or /opt/coredns/. Make it executable:
chmod +x /usr/local/bin/coredns
-
Create a Systemd Service (Recommended for Linux): This will automatically start CoreDNS on boot and manage its lifecycle. Create a file named /etc/systemd/system/coredns.service:
[Unit]
Description=CoreDNS DNS Server
After=network.target
[Service]
User=coredns # You might need to create this user
Group=coredns # You might need to create this group
ExecStart=/usr/local/bin/coredns -conf /etc/coredns/Corefile
Restart=on-failure
[Install]
WantedBy=multi-user.target
- Important:
- You might need to create the
coredns user and group: sudo useradd -r -m -d /var/lib/coredns -s /usr/sbin/nologin coredns and sudo groupadd coredns. Adjust the -d parameter if you would like to use another data directory.
- Adjust the paths in
ExecStart to match where you placed the coredns executable and Corefile.
-
Enable and Start the Service:
sudo systemctl enable coredns.service
sudo systemctl start coredns.service
sudo systemctl status coredns.service # Check status
Configuration (Corefile):
Create a file named /etc/coredns/Corefile (or wherever you specified in the ExecStart line of your systemd service) with the following content:
.:53 {
log
errors
forward . dns.usc.edu {
except office.internal
}
office.internal {
file /etc/coredns/db.office.internal
dynamic
}
prometheus :9153
health :8080
}
Explanation of Corefile:
.:53: Listen on all interfaces (.) on port 53 (the standard DNS port).
log: Enables logging of DNS queries (helpful for debugging).
errors: Logs errors to stderr.
forward . dns.usc.edu: Forwards all DNS queries to dns.usc.edu.
except office.internal: Except the queries with domains of office.internal
office.internal: Defines the zone for office.internal.
file /etc/coredns/db.office.internal: Loads initial DNS records from the /etc/coredns/db.office.internal file.
dynamic: enables dynamic DNS updates.
prometheus :9153: Exposes metrics for Prometheus monitoring (optional, but recommended for production).
health :8080: Provides a health check endpoint (optional, but recommended for production).
Initial Zone File (/etc/coredns/db.office.internal):
This file should contain initial DNS records for your .office.internal domain. It's similar to a BIND zone file.
$ORIGIN office.internal.
$TTL 3600
@ IN SOA ns1.office.internal. admin.office.internal. (
2023102701 ; Serial
3600 ; Refresh
600 ; Retry
86400 ; Expire
3600 ; Minimum TTL
)
IN NS ns1.office.internal.
ns1 IN A 127.0.0.1 ; Replace with the actual IP of the CoreDNS server.
$ORIGIN: Sets the origin for relative domain names.
$TTL: Sets the default TTL (Time-To-Live) for records.
SOA: Start of Authority record. ns1.office.internal. is the primary nameserver for the zone, and admin.office.internal. is the email address of the administrator (replace @ with .). The serial number should be incremented whenever you modify the zone file manually.
NS: Nameserver record pointing to the DNS server responsible for the zone.
Dynamic DNS Updates:
-
Configure Clients: On each workstation, you'll need to use a dynamic DNS client to send updates to the CoreDNS server. Popular clients include nsupdate (part of BIND utilities), ddclient, or a custom script using nsupdate commands.
-
TSIG (Transaction Signature) Authentication (Highly Recommended): For security, you should use TSIG keys to authenticate dynamic updates. This prevents unauthorized machines from modifying the DNS records.
-
Generate a TSIG Key: On the CoreDNS server:
dnssec-keygen -a HMAC-SHA256 -b 256 -n HOST dynamic.office.internal.
This will generate two files: Kdydynamic.office.internal.+166+XXXXX.key (private key) and Kdydynamic.office.internal.+166+XXXXX.private (contains both public and private key). The XXXXX part will be different for your key.
-
Add TSIG Support to Corefile: Edit your Corefile to include the key directive in the office.internal block:
office.internal {
file /etc/coredns/db.office.internal
dynamic {
key dynamic.office.internal Kdydynamic.office.internal.+166+XXXXX.private
}
}
Replace Kdydynamic.office.internal.+166+XXXXX.private with the actual path to the private key file.
-
Configure the Client: Configure your dynamic DNS client on each workstation to use the same TSIG key when sending updates. The configuration will vary depending on the client. For nsupdate, you'll need to specify the key name and the base64-encoded secret in the nsupdate commands. Example:
server <coredns-server-ip>
update add workstation1.office.internal. 60 A 192.168.1.100
send
You'll also need to add this information in a nsupdate command file (e.g., update.txt):
server <coredns-server-ip>
key dynamic.office.internal. <base64-encoded-secret>
update add workstation1.office.internal. 60 A 192.168.1.100
send
Then run: nsupdate -k Kdydynamic.office.internal.+166+XXXXX.key update.txt
Replace <base64-encoded-secret> with the actual base64 encoded secret from Kdydynamic.office.internal.+166+XXXXX.private.
-
Configure nsupdate: Here's a sample shell script snippet for dynamically updating the DNS record for :
Important Considerations:
- Firewall: Ensure your firewall allows DNS traffic (port 53) to and from the CoreDNS server.
- Security: Implement TSIG authentication to prevent unauthorized DNS updates.
- Monitoring: Set up monitoring for your CoreDNS server to ensure it's running and responding to queries. The Prometheus and health check plugins can help with this.
- Testing: Thoroughly test the dynamic DNS updates to ensure they are working correctly. Use
nslookup or dig to verify that the records are being updated as expected.
Alternative Options (Less Recommended but Possible):
- BIND9 (BIND): BIND is the classic DNS server, and while powerful, it's overkill for this relatively simple scenario. It's also more complex to configure than CoreDNS.
- PowerDNS: PowerDNS is another option, known for its flexibility and database backends. It's still more heavyweight than CoreDNS.
- Unbound: Primarily a validating recursive resolver, but it can be configured as an authoritative server with static records. No native support for dynamic updates without external tools/scripts.
Summary of Configuration Steps:
- Install CoreDNS.
- Create a
coredns user and group.
- Create
/etc/coredns/Corefile with the configuration described above.
- Create
/etc/coredns/db.office.internal with the initial zone data.
- Enable and start the
coredns.service using systemctl.
- Generate a TSIG key.
- Add the TSIG key configuration to the
Corefile.
- Configure each workstation with a dynamic DNS client (e.g.,
nsupdate) and the TSIG key.
- Test the dynamic DNS updates.
CoreDNS gives you a balance of functionality, performance, and ease of configuration for your specific requirements. Remember to adjust paths and IP addresses in the configuration files to match your environment.