SlideShare a Scribd company logo
SFScon 2022
Manage your own DNS
Dashamir Hoxha
dashohoxha@gmail.com
How to manage your own DNS
When you purchase a domain, the seller of the domain usually
offers the possibility to manage the DNS records of this domain
from a web interface. In this case you are using their nameservers.
However it is also possible to manage your domains yourself, and it
is not too difficult. In this presentation I will show how I do it.
How DNS works
Let’s see how a client (browser) finds the IP for cloud.example.org
➢ Contact a root nameserver and ask it which servers are
responsible for managing the top-level domain .org
➢ From the query on the first step the client gets a list of the
servers responsible for the domain .org, it can ask any of
them for the servers that are responsible for the
subdomain example.org
➢ From the query on the previous step it will get a list of
nameservers for the domain example.org, for example:
○ ns1.example.org
○ ns2.example.org
➢ Ask any of these nameservers for the IP of the server
cloud.example.org
How DNS works
Let’s try these steps manually for the domain ocw.fs.al
1. Get the root nameservers:
dig NS .
dig NS . +short
m.root-servers.net.
b.root-servers.net.
c.root-servers.net.
. . . . .
2. Get the nameservers of .al:
dig NS al @m.root-servers.net.
dig NS al +short
rip.psg.com.
nsx.nic.al.
ns1.nic.al.
munnari.oz.au.
3. Get the nameservers of .fs.al:
dig NS fs.al @nsx.nic.al.
dig NS fs.al +short
puck.nether.net.
ns0.1984.is.
ns2.afraid.org.
4. Get the address of ocw.fs.al:
dig A ocw.fs.al +short
5.45.111.246
Keeping nameservers synchronized
★ All the public nameservers get their
records from the primary NS, which is
hidden behind a firewall.
★ Only secondary NSs answer queries
from the clients, not the primary.
★ When there are any changes on the
records of the primary NS, it sends a
notification to the secondary ones.
★ Secondary nameservers send a
synchronization request (AXFR) to the
primary one
★ Upon receiving the list of new records,
they replace the old list of records with
the new one.
DNS Setup: Find secondary NS services
Instead of building and maintaining our own secondary nameservers, we
can use services that are available either for free or for a small price.
● https://www.buddyns.com/activation/
● https://1984hosting.com/product/freedns/
● https://puck.nether.net/dns/
● https://freedns.afraid.org/
Note: The "primary/secondary" nameservers are also called
"master/slave".
DNS Setup: Install the primary nameserver
The primary nameserver will be installed in an NSD container.
1. Install docker-scripts:
apt install git make m4 highlight
git clone https://gitlab.com/docker-scripts/ds
/opt/docker-scripts/ds
cd /opt/docker-scripts/ds/
make install
2. Install an NSD container:
ds pull nsd
ds init nsd @nsd
cd /var/ds/nsd/
vim settings.sh
ds make
DNS Setup: Make sure that port 53 is free
The NSD container needs access to the port 53 of the host: lsof -i :53
We should prevent systemd-resolved from using port 53:
1. Edit /etc/systemd/resolved.conf:
[Resolve]
DNS=8.8.8.8
DNSStubListener=no
. . . . .
2. Create a symbolic link:
ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf
3. Reboot the system
4. Check that port 53 is now free: lsof -i :53
5. Try again: ds make
DNS Setup: Customize secondary nameservers
On settings.sh, edit the constants SECONDARY_NS and AXFR_SERVERS.
Then run again: ds make
SECONDARY_NS="
ns0.1984.is
puck.nether.net
ns2.afraid.org
"
AXFR_SERVERS="
93.95.224.6
204.42.254.5
69.65.50.192
108.61.224.67
116.203.6.3
. . . . .
“
Manage domains: Add a domain
Let’s say that we have purchased the domain example.org
1. Set the nameservers of the domain (what is on SECONDARY_NS):
ns0.1984.is
puck.nether.net
ns2.afraid.org
2. Add the domain to each secondary NS service
https://www.buddyns.com/
https://1984.hosting/product/freedns/
https://puck.nether.net/dns
https://freedns.afraid.org/secondary/
3. Add a zone on the primary nameserver:
cd /var/ds/nsd/
ds zone add example.org
Manage domains: Modify DNS records
1. Edit zones/example.org.db and modify the records:
cd /var/ds/nsd/
vim zones/example.org.db
2. Don’t forget to change the serial number too:
2022061901 ; serial
3. Notify the secondary nameservers that there are some updates:
ds notify
Alternatively, a ds restart will also reload the zones and send
notifications to the secondary nameservers.
Manage domains: Remove a domain
1. Remove it from each secondary nameserver service.
2. Remove its configuration on the primary server:
cd /var/ds/nsd/
ds zone rm example.org
3. Alternatively, disable its configuration:
ds zone dis example.org
Troubleshooting
1. We can make some simple checks and tests like this:
ds check --config
ds check --zones
2. To check the AXFR response for a domain:
ds zone test example.org
It will actually list all the records that will be sent to a secondary nameserver.
3. For further troubleshooting, we can get a shell inside the container and try
commands like these:
systemctl restart nsd
systemctl status nsd
tail /var/log/syslog -n 30
dig @localhost AXFR example.org
ufw status
Maintenance: Migrate the primary nameserver
To migrate the container of the primary nameserver to another host:
1. Transfer (with scp or rsync) the content of /var/ds/nsd/ from the old host
to the new one.
2. On the new host, rebuild the container:
ds pull nsd
cd /var/ds/nsd/
ds make
3. The public IP of the master nameserver has been changed (to the IP of the new
host), so we should update it on the configuration of each secondary
nameserver, for each domain.
4. Replace the old IP with the new one on each zone file as well, then update the
serial numbers and notify the secondary nameservers.
Maintenance: Modify secondary nameservers
If you need to modify the list of secondary nameservers, for example add
ns1.1984.is on the list, or remove one from the list, you should also make sure to
update these things:
1. For each domain that you manage, go to the website of the provider of the
domain and update the list of the nameservers.
2. If you are adding a new secondary nameserver, go to the website of the
nameserver and make sure that you add there all the domains that you manage,
along with the public IP of the primary nameserver.
3. On the primary nameserver, update settings.sh accordingly and then run
ds make
to update the configuration files.
Thank you for your attention!
Any questions or comments?
➔ Dashamir Hoxha (dashohoxha@gmail.com)
➔ https://docker-scripts.gitlab.io/dns.html (Tutorial)
➔ https://events.fs.al/event/8/registrations/ (Workshop)
Tutorial: Workshop:

More Related Content

PDF
DNS BIND Cookbook 1st Edition Cricket Liu
PPT
Domain Name Service
PDF
Alternative Dns Servers Choice And Deployment And Optional Sql Ldap Backends ...
PDF
1. primary dns using bind for a and cname record for ipv4 and ipv6
PPTX
linux networking commands short
PPTX
Linux networking commands short
PDF
2. reverse primarydns using bind for ptr and cname record ipv4
PPSX
Linux04 dns 2
DNS BIND Cookbook 1st Edition Cricket Liu
Domain Name Service
Alternative Dns Servers Choice And Deployment And Optional Sql Ldap Backends ...
1. primary dns using bind for a and cname record for ipv4 and ipv6
linux networking commands short
Linux networking commands short
2. reverse primarydns using bind for ptr and cname record ipv4
Linux04 dns 2

Similar to SFScon 22 - Dashamir Hoxha - Manage your own DNS.pdf (20)

PPS
Linux15 dynamic dns-2
PPT
Linux15 dynamic dns-2
PDF
DNS and BIND, 5th Edition.pdf
PPTX
DNS for Developers - ConFoo Montreal
PPTX
Linux networking commands
PPTX
Linux networking commands
DOCX
Linux basics andng hosti
PDF
PPTX
DNS for Developers - NDC Oslo 2016
PPTX
Dns server setup on ubuntu vps (master+slave)
DOCX
DNS windows server(2008R2) & linux(SLES 11)
PPTX
DNS SERVER
PDF
3. reverse primarydns using bind for ptr and cname record ipv6
PDF
Nameserver: What Is It And What Does It Do?
PPTX
DNS.pptx
PPTX
BIND DNS Configuration Red Hat 5
PPTX
2_Chapter 2_DNS.pptx
PDF
6. reverse primarydns using bind for ptr and cname record ipv6 with forwarder
PPT
3_CHAP~2.PPT
Linux15 dynamic dns-2
Linux15 dynamic dns-2
DNS and BIND, 5th Edition.pdf
DNS for Developers - ConFoo Montreal
Linux networking commands
Linux networking commands
Linux basics andng hosti
DNS for Developers - NDC Oslo 2016
Dns server setup on ubuntu vps (master+slave)
DNS windows server(2008R2) & linux(SLES 11)
DNS SERVER
3. reverse primarydns using bind for ptr and cname record ipv6
Nameserver: What Is It And What Does It Do?
DNS.pptx
BIND DNS Configuration Red Hat 5
2_Chapter 2_DNS.pptx
6. reverse primarydns using bind for ptr and cname record ipv6 with forwarder
3_CHAP~2.PPT
Ad

More from South Tyrol Free Software Conference (20)

PDF
SFSCON24 - Marina Latini - 1, 2, 3, Doc Kit!
PDF
SFSCON24 - Carmen Delgado Ivar Grimstad - Nurturing OpenJDK distribution: Ecl...
PDF
SFSCON24 - Eduardo Guerra - codEEmoji – Making code more informative with emojis
PDF
SFSCON24 - Juri Solovjov - How to start contributing and still have fun
PDF
SFSCON24 - Michal Skipala & Bruno Rossi - Monolith Splitter
PDF
SFSCON24 - Jorge Melegati - Software Engineering Automation: From early tools...
PDF
SFSCON24 - Chiara Civardi & Dominika Tasarz Sochacka - The Crucial Role of Op...
PDF
SFSCON24 - Moritz Mock, Barbara Russo & Jorge Melegati - Can Test Driven Deve...
PDF
SFSCON24 - Aurelio Buonomo & Christian Zanotti - Apisense – Easily monitor an...
PDF
SFSCON24 - Giovanni Giannotta & Orneda Lecini - Approaches to Object Detectio...
PDF
SFSCON24 - Alberto Nicoletti - The SMART Box of AURA Project
PDF
SFSCON24 - Luca Alloatti - Open-source silicon chips
PDF
SFSCON24 - Roberto Innocenti - 2025 scenario on OpenISA OpenPower Open Hardwa...
PDF
SFSCON24 - Juan Rico - Enabling global interoperability among smart devices ...
PDF
SFSCON24 - Seckin Celik & Davide Serpico - Adoption Determinants of Open Hard...
PDF
SFSCON24 - Stefan Mutschlechner - Smart Werke Meran - Lorawan Use Cases
PDF
SFSCON24 - Mattia Pizzirani - Raspberry Pi and Node-RED: Open Source Tools fo...
PDF
SFSCON24 - Attaullah Buriro - ClapMetrics: Decoding Users Genderand Age Throu...
PDF
SFSCON24 - Joseph P. De Veaugh Geiss - Opt out? Opt in? Opt Green! Bringing F...
PDF
SFSCON24 - Fulvio Mastrogiovanni - On the ethical challenges raised by robots...
SFSCON24 - Marina Latini - 1, 2, 3, Doc Kit!
SFSCON24 - Carmen Delgado Ivar Grimstad - Nurturing OpenJDK distribution: Ecl...
SFSCON24 - Eduardo Guerra - codEEmoji – Making code more informative with emojis
SFSCON24 - Juri Solovjov - How to start contributing and still have fun
SFSCON24 - Michal Skipala & Bruno Rossi - Monolith Splitter
SFSCON24 - Jorge Melegati - Software Engineering Automation: From early tools...
SFSCON24 - Chiara Civardi & Dominika Tasarz Sochacka - The Crucial Role of Op...
SFSCON24 - Moritz Mock, Barbara Russo & Jorge Melegati - Can Test Driven Deve...
SFSCON24 - Aurelio Buonomo & Christian Zanotti - Apisense – Easily monitor an...
SFSCON24 - Giovanni Giannotta & Orneda Lecini - Approaches to Object Detectio...
SFSCON24 - Alberto Nicoletti - The SMART Box of AURA Project
SFSCON24 - Luca Alloatti - Open-source silicon chips
SFSCON24 - Roberto Innocenti - 2025 scenario on OpenISA OpenPower Open Hardwa...
SFSCON24 - Juan Rico - Enabling global interoperability among smart devices ...
SFSCON24 - Seckin Celik & Davide Serpico - Adoption Determinants of Open Hard...
SFSCON24 - Stefan Mutschlechner - Smart Werke Meran - Lorawan Use Cases
SFSCON24 - Mattia Pizzirani - Raspberry Pi and Node-RED: Open Source Tools fo...
SFSCON24 - Attaullah Buriro - ClapMetrics: Decoding Users Genderand Age Throu...
SFSCON24 - Joseph P. De Veaugh Geiss - Opt out? Opt in? Opt Green! Bringing F...
SFSCON24 - Fulvio Mastrogiovanni - On the ethical challenges raised by robots...
Ad

Recently uploaded (20)

PPTX
Computer Software and OS of computer science of grade 11.pptx
PDF
How Tridens DevSecOps Ensures Compliance, Security, and Agility
PDF
iTop VPN Crack Latest Version Full Key 2025
PDF
Designing Intelligence for the Shop Floor.pdf
PDF
Topaz Photo AI Crack New Download (Latest 2025)
PPTX
Cybersecurity: Protecting the Digital World
PDF
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
PDF
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
PDF
Salesforce Agentforce AI Implementation.pdf
PPTX
chapter 5 systemdesign2008.pptx for cimputer science students
PDF
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
PDF
MCP Security Tutorial - Beginner to Advanced
PDF
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
PPTX
Custom Software Development Services.pptx.pptx
PDF
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
PPTX
Oracle Fusion HCM Cloud Demo for Beginners
PDF
Website Design Services for Small Businesses.pdf
PPTX
Introduction to Windows Operating System
PPTX
Tech Workshop Escape Room Tech Workshop
PPTX
Weekly report ppt - harsh dattuprasad patel.pptx
Computer Software and OS of computer science of grade 11.pptx
How Tridens DevSecOps Ensures Compliance, Security, and Agility
iTop VPN Crack Latest Version Full Key 2025
Designing Intelligence for the Shop Floor.pdf
Topaz Photo AI Crack New Download (Latest 2025)
Cybersecurity: Protecting the Digital World
Ableton Live Suite for MacOS Crack Full Download (Latest 2025)
EaseUS PDF Editor Pro 6.2.0.2 Crack with License Key 2025
Salesforce Agentforce AI Implementation.pdf
chapter 5 systemdesign2008.pptx for cimputer science students
How AI/LLM recommend to you ? GDG meetup 16 Aug by Fariman Guliev
MCP Security Tutorial - Beginner to Advanced
Product Update: Alluxio AI 3.7 Now with Sub-Millisecond Latency
Custom Software Development Services.pptx.pptx
AI-Powered Threat Modeling: The Future of Cybersecurity by Arun Kumar Elengov...
Oracle Fusion HCM Cloud Demo for Beginners
Website Design Services for Small Businesses.pdf
Introduction to Windows Operating System
Tech Workshop Escape Room Tech Workshop
Weekly report ppt - harsh dattuprasad patel.pptx

SFScon 22 - Dashamir Hoxha - Manage your own DNS.pdf

  • 1. SFScon 2022 Manage your own DNS Dashamir Hoxha dashohoxha@gmail.com
  • 2. How to manage your own DNS When you purchase a domain, the seller of the domain usually offers the possibility to manage the DNS records of this domain from a web interface. In this case you are using their nameservers. However it is also possible to manage your domains yourself, and it is not too difficult. In this presentation I will show how I do it.
  • 3. How DNS works Let’s see how a client (browser) finds the IP for cloud.example.org ➢ Contact a root nameserver and ask it which servers are responsible for managing the top-level domain .org ➢ From the query on the first step the client gets a list of the servers responsible for the domain .org, it can ask any of them for the servers that are responsible for the subdomain example.org ➢ From the query on the previous step it will get a list of nameservers for the domain example.org, for example: ○ ns1.example.org ○ ns2.example.org ➢ Ask any of these nameservers for the IP of the server cloud.example.org
  • 4. How DNS works Let’s try these steps manually for the domain ocw.fs.al 1. Get the root nameservers: dig NS . dig NS . +short m.root-servers.net. b.root-servers.net. c.root-servers.net. . . . . . 2. Get the nameservers of .al: dig NS al @m.root-servers.net. dig NS al +short rip.psg.com. nsx.nic.al. ns1.nic.al. munnari.oz.au. 3. Get the nameservers of .fs.al: dig NS fs.al @nsx.nic.al. dig NS fs.al +short puck.nether.net. ns0.1984.is. ns2.afraid.org. 4. Get the address of ocw.fs.al: dig A ocw.fs.al +short 5.45.111.246
  • 5. Keeping nameservers synchronized ★ All the public nameservers get their records from the primary NS, which is hidden behind a firewall. ★ Only secondary NSs answer queries from the clients, not the primary. ★ When there are any changes on the records of the primary NS, it sends a notification to the secondary ones. ★ Secondary nameservers send a synchronization request (AXFR) to the primary one ★ Upon receiving the list of new records, they replace the old list of records with the new one.
  • 6. DNS Setup: Find secondary NS services Instead of building and maintaining our own secondary nameservers, we can use services that are available either for free or for a small price. ● https://www.buddyns.com/activation/ ● https://1984hosting.com/product/freedns/ ● https://puck.nether.net/dns/ ● https://freedns.afraid.org/ Note: The "primary/secondary" nameservers are also called "master/slave".
  • 7. DNS Setup: Install the primary nameserver The primary nameserver will be installed in an NSD container. 1. Install docker-scripts: apt install git make m4 highlight git clone https://gitlab.com/docker-scripts/ds /opt/docker-scripts/ds cd /opt/docker-scripts/ds/ make install 2. Install an NSD container: ds pull nsd ds init nsd @nsd cd /var/ds/nsd/ vim settings.sh ds make
  • 8. DNS Setup: Make sure that port 53 is free The NSD container needs access to the port 53 of the host: lsof -i :53 We should prevent systemd-resolved from using port 53: 1. Edit /etc/systemd/resolved.conf: [Resolve] DNS=8.8.8.8 DNSStubListener=no . . . . . 2. Create a symbolic link: ln -sf /run/systemd/resolve/resolv.conf /etc/resolv.conf 3. Reboot the system 4. Check that port 53 is now free: lsof -i :53 5. Try again: ds make
  • 9. DNS Setup: Customize secondary nameservers On settings.sh, edit the constants SECONDARY_NS and AXFR_SERVERS. Then run again: ds make SECONDARY_NS=" ns0.1984.is puck.nether.net ns2.afraid.org " AXFR_SERVERS=" 93.95.224.6 204.42.254.5 69.65.50.192 108.61.224.67 116.203.6.3 . . . . . “
  • 10. Manage domains: Add a domain Let’s say that we have purchased the domain example.org 1. Set the nameservers of the domain (what is on SECONDARY_NS): ns0.1984.is puck.nether.net ns2.afraid.org 2. Add the domain to each secondary NS service https://www.buddyns.com/ https://1984.hosting/product/freedns/ https://puck.nether.net/dns https://freedns.afraid.org/secondary/ 3. Add a zone on the primary nameserver: cd /var/ds/nsd/ ds zone add example.org
  • 11. Manage domains: Modify DNS records 1. Edit zones/example.org.db and modify the records: cd /var/ds/nsd/ vim zones/example.org.db 2. Don’t forget to change the serial number too: 2022061901 ; serial 3. Notify the secondary nameservers that there are some updates: ds notify Alternatively, a ds restart will also reload the zones and send notifications to the secondary nameservers.
  • 12. Manage domains: Remove a domain 1. Remove it from each secondary nameserver service. 2. Remove its configuration on the primary server: cd /var/ds/nsd/ ds zone rm example.org 3. Alternatively, disable its configuration: ds zone dis example.org
  • 13. Troubleshooting 1. We can make some simple checks and tests like this: ds check --config ds check --zones 2. To check the AXFR response for a domain: ds zone test example.org It will actually list all the records that will be sent to a secondary nameserver. 3. For further troubleshooting, we can get a shell inside the container and try commands like these: systemctl restart nsd systemctl status nsd tail /var/log/syslog -n 30 dig @localhost AXFR example.org ufw status
  • 14. Maintenance: Migrate the primary nameserver To migrate the container of the primary nameserver to another host: 1. Transfer (with scp or rsync) the content of /var/ds/nsd/ from the old host to the new one. 2. On the new host, rebuild the container: ds pull nsd cd /var/ds/nsd/ ds make 3. The public IP of the master nameserver has been changed (to the IP of the new host), so we should update it on the configuration of each secondary nameserver, for each domain. 4. Replace the old IP with the new one on each zone file as well, then update the serial numbers and notify the secondary nameservers.
  • 15. Maintenance: Modify secondary nameservers If you need to modify the list of secondary nameservers, for example add ns1.1984.is on the list, or remove one from the list, you should also make sure to update these things: 1. For each domain that you manage, go to the website of the provider of the domain and update the list of the nameservers. 2. If you are adding a new secondary nameserver, go to the website of the nameserver and make sure that you add there all the domains that you manage, along with the public IP of the primary nameserver. 3. On the primary nameserver, update settings.sh accordingly and then run ds make to update the configuration files.
  • 16. Thank you for your attention! Any questions or comments? ➔ Dashamir Hoxha (dashohoxha@gmail.com) ➔ https://docker-scripts.gitlab.io/dns.html (Tutorial) ➔ https://events.fs.al/event/8/registrations/ (Workshop) Tutorial: Workshop: