A tiny DNS server that is capable of serving records configured in a MySQL table, or configured statically in a JSON file
-
mode: Can be eitherdbif your records are stored in a MySQL database, orstatic_recordsif your records are static and stored in the configuration JSON file. -
query_logging: Should the DNS server log queries made to it? Enable this if yes. -
db: The MySQL server & database credentials. This works only ifmodeis set todb -
listener: The listening/bind settings for the DNS server (usually has to be kept binding on port 53 to be able to accept DNS requests). -
process_unstored_dns_queries: Should the DNS server also accept queries of records that are not stored in your database table/static records configuration? Enable this if yes. -
static_records: Configure your static records here, one per JSON object. This works only ifmodeis set tostatic_records
- Store your configuration file at
/etc/simpledns/config.jsonYou can copy the example configuration file and change it to serve your needs. - If running Simple DNS server in the
dbmode, use this database structure for your records table: https://github.com/oddmario/simple-dns-server/blob/main/db_structure.sql - Place the binary file of Simple DNS server at
/usr/local/bin(e.g./usr/local/bin/simpledns) - Make the binary file executable:
chmod u+x /usr/local/bin/simpledns - Create a systemd service for the application. This can be done by creating /etc/systemd/system/simpledns.service to have this content:
[Unit]
Description=SimpleDNSserver
[Service]
User=root
WorkingDirectory=/usr/local/bin
LimitNOFILE=2097152
TasksMax=infinity
ExecStart=/usr/local/bin/simpledns /etc/simpledns/config.json
Restart=on-failure
StartLimitInterval=180
StartLimitBurst=30
RestartSec=5s
[Install]
WantedBy=multi-user.target
- Port 53 (the DNS server port) is usually in use by default. To solve this, follow https://unix.stackexchange.com/a/676977/405697 then run
systemctl restart systemd-resolved - Make sure that no other DNS servers (such as bind9) are running
- Enable the Simple DNS server service on startup & start it now:
systemctl enable --now simpledns.service