Skip to main content

Raymii.org Raymii.org Logo

Quis custodiet ipsos custodes?
Home | About | All pages | Cluster Status | RSS Feed | Gopher

Match dig 127.0.0.53 server with systemd-resolvd server

Published: 23-05-2019 | Author: Remy van Elst | Text only version of this article


❗ This post is over one year old. It may no longer be up to date. Opinions may have changed.

Table of Contents


On systems that use systemd-resolved for DNS you will see the 127.0.0.53 IP address in dig output. dig is a tool to do DNS lookups, and for troubleshooting it's usefull to see which server is being queried. With systemd-resolved, you need to issue another command to view the actual server that is being queried, since systemd-resolved also acts as a local caching server.

Consider sponsoring me on Github. It means the world to me if you show your appreciation and you'll help pay the server costs.

You can also sponsor me by getting a Digital Ocean VPS. With this referral link you'll get $100 credit for 60 days.

dig query

Using the following example of a default dig query you will see in the output a line saying "SERVER", which is the server answering the query:

$ dig A raymii.org

; <<>> DiG 9.11.3-1ubuntu1.7-Ubuntu <<>> A raymii.org
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 23416
;; flags: qr rd ra; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 65494
;; QUESTION SECTION:
;raymii.org.            IN  A

;; ANSWER SECTION:
raymii.org.     300 IN  A   45.32.136.37
raymii.org.     300 IN  A   80.211.96.38
raymii.org.     300 IN  A   116.203.75.71
raymii.org.     300 IN  A   199.19.225.3
raymii.org.     300 IN  A   185.121.24.135
raymii.org.     300 IN  A   212.47.241.60
raymii.org.     300 IN  A   128.199.39.10

;; Query time: 12 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)
;; WHEN: Thu May 23 09:07:29 CEST 2019
;; MSG SIZE  rcvd: 151

This line:

;; SERVER: 127.0.0.53#53(127.0.0.53)

If we give dig a specific DNS server to query you will see that reflected in the output:

$ dig A raymii.org @8.8.8.8

; <<>> DiG 9.11.3-1ubuntu1.7-Ubuntu <<>> A raymii.org @8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 63820
;; flags: qr rd ra ad; QUERY: 1, ANSWER: 7, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;raymii.org.            IN  A

;; ANSWER SECTION:
raymii.org.     286 IN  A   116.203.75.71
raymii.org.     286 IN  A   185.121.24.135
raymii.org.     286 IN  A   212.47.241.60
raymii.org.     286 IN  A   199.19.225.3
raymii.org.     286 IN  A   45.32.136.37
raymii.org.     286 IN  A   128.199.39.10
raymii.org.     286 IN  A   80.211.96.38

;; Query time: 9 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Thu May 23 09:09:01 CEST 2019
;; MSG SIZE  rcvd: 151

The line now reflects the google dns:

;; SERVER: 8.8.8.8#53(8.8.8.8)

systemd-resolved

When debugging, for example when an internal DNS server gives different results, you would want to know which internal dns server answered the request, instead of seeing that it was your local resolver. If you are using systemd-resolved (default on Ubuntu 18.04) the following command will show the actual upstream DNS server (received from DHCP) used:

systemd-resolve --status | grep "DNS Servers"

Example output:

     DNS Servers: 192.168.55.254

If you have more than one network interface you will need to look at the full command output.

Tags: bash , bind , dig , dns , resolved , shell , snippets , systemd , systemd-resolved