diff --git a/content/posts/dns/dnsupdate/index.en.md b/content/posts/dns/dnsupdate/index.en.md new file mode 100644 index 0000000..4919115 --- /dev/null +++ b/content/posts/dns/dnsupdate/index.en.md @@ -0,0 +1,128 @@ ++++ +title = "A little dynamic in my DNS" +date = 2022-05-28T18:40:11+02:00 +draft = false +categories = ["dns"] +tags = ["dns"] +author = "Yann Verry" +description = "" ++++ + +Today in the computer world almost *100%* works with API. +DNS servers are no exception, for example with PowerDNS without surprise there is an API but let's explore what works very well since years: **DNSUpdate** with its little RFC[2136](https://datatracker.ietf.org/doc/html/rfc2136.html). + +## DynDNS + +In 2022 many ISPs do not provide fixed *IPv4* or *IPv6*. So it changes regularly depending on a power cut or more from your operator. +There are many online services to do this job via an API, maybe even your registrar. +But when you host your own DNS, it is easier to use **nsupdate** which is often already installed on your machine when you need to dig into the question. Otherwise it is present for example via the *bind9-dnsutils* package under debian. + +So we will make a small script that will get its ipv4 and v6 public and update them, here on the server **dnsupdate.verry.org** : + + +```bash +DOMAIN="verry.org" +HOST="raoul.verry.org" +ORIG_IPv4=$(dig +short a $HOST @dnsupdate.verry.org) +ORIG_IPv6=$(dig +short aaaa $HOST @dnsupdate.verry.org) +IPv4=$(curl -4 https://ip.verry.org) +IPv6=$(curl -6 https://ip.verry.org) +SERVER=$(dig +short aaaa dnsupdate.verry.org) + +if [ "$ORIG_IPv4" != "$IPv4" ] || [ "$ORIG_IPv6" != "$IPv6" ]; +then + +nsupdate -y '::' <::' <::' <