Changing DNS on Dietpi

Creating a bug report/issue

Required Information

  • DietPi version | G_DIETPI_VERSION_CORE=8 G_DIETPI_VERSION_SUB=7 G_DIETPI_VERSION_RC=1 G_GITBRANCH='master' G_GITOWNER='MichaIng G_LIVE_PATCH_STATUS[0]='not applicable'
  • Distro version | bullseye 0
  • Kernel version | Linux DietPi 5.15.56-v8+ #1575 SMP PREEMPT Fri Jul 22 20:31:26 BST 2022 aarch64 GNU/Linux
  • SBC model | RPi 4 Model B (aarch64)
  • Power supply used | (EG: 5V 2A )
  • SD card used | (EG: Blank Brand)

Additional Information (if applicable)

Steps to reproduce

  1. dietpi-config β†’ network options β†’ adapter options β†’ change wired network settings
  2. dietpiChange DNS from 8.8.8.8 to Cloudfare (1.1.1.1 1.0.0.1)
  3. Apply settings

Expected behaviour

Change the DNS

Actual behaviour

prints: β€œrtnetlink answers no such process” and can’t connect to the network

DonΒ΄t know if I’m missing something.

Thank you in advance

Can you share following

cat /etc/resolv.conf

I flashed the sd card because I didn’t had any acess via ssh or hdmi (I don’t have a micro-hdmi adpter). So I couldn’t have any visual feedback.

cat /etc/resolv.conf:

domain lan
search lan
nameserver 192.168.1.1

One thing that can cause this error is specifying a gateway or other network value on an invalid subnet. For example, it looks like your gateway is on the 192.168.1.0/24 subnet; if you try to set a static IP for your device on the 192.168.0.0/24 subnet by mistake that could cause this.

Copy and paste the rest of the DietPi-Config page into the thread so we can take a look and maybe help you spot a misconfiguration. This is the page I mean:

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ DietPi-Config β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Ethernet Details:                                                        β”‚
β”‚ Usage   : Sent = 21742 MiB | Recieved = 34595 MiB                        β”‚
β”‚ Address : IP = 192.168.0.10 | Mask = 255.255.255.0 | Gateway =           β”‚
β”‚ 192.168.0.1 | DNS = 192.168.0.14                                         β”‚
β”‚                                                                          β”‚
β”‚                        ●─ DHCP/STATIC IP ──────────────────────●         β”‚
β”‚         Change Mode    : [STATIC]                                        β”‚
β”‚         Copy           : Copy current address to "Static"                β”‚
β”‚         Static IP      : [192.168.0.100]                                 β”‚
β”‚         Static Mask    : [255.255.255.0]                                 β”‚
β”‚         Static Gateway : [192.168.0.1]                                   β”‚
β”‚         Static DNS     : [192.168.0.14]                                  β”‚
β”‚                        ●─ Additional Options ──────────────────●         β”‚
β”‚         Link Speed     : [auto (default)]                                β”‚
β”‚         Disable        : Disable Ethernet adapter                        β”‚
β”‚                        ●─ Apply ───────────────────────────────●         β”‚
β”‚         Apply          : Save all changes and restart networking         β”‚
β”‚                                                                          β”‚
β”‚                                                                          β”‚
β”‚                   <Ok>                       <Back>                      β”‚
β”‚                                                                          β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

1st try

+------------------------------Β¦ DietPi-Config +-------------------------------+
Β¦ Ethernet Details:                                                            Β¦
Β¦ Usage   : Sent = 56 MiB | Recieved = 204 MiB                                 Β¦
Β¦ Address : IP = 192.168.1.111 | Mask = 255.255.255.0 | Gateway = 192.168.1.1  Β¦
Β¦ | DNS = 192.168.1.1                                                          Β¦
Β¦                                                                              Β¦
Β¦                          ?- DHCP/STATIC IP ----------------------?           Β¦
Β¦           Change Mode    : [STATIC]                                          Β¦
Β¦           Copy           : Copy current address to "Static"                  Β¦
Β¦           Static IP      : [192.168.0.100]                                   Β¦
Β¦           Static Mask    : [255.255.255.0]                                   Β¦
Β¦           Static Gateway : [192.168.0.1]                                     Β¦
Β¦           Static DNS     : [192.168.1.1]                                     Β¦
Β¦                          ?- Additional Options ------------------?           Β¦
Β¦           Link Speed     : [auto (default)]                                  Β¦
Β¦           Disable        : Disable Ethernet adapter                          Β¦
Β¦                          ?- Apply -------------------------------?           Β¦
Β¦           Apply          : Save all changes and restart networking           Β¦
Β¦                                                                              Β¦
Β¦                                                                              Β¦
Β¦                     <Ok>                         <Back>                      Β¦
Β¦                                                                              Β¦
+------------------------------------------------------------------------------+

Tested with backup raspberry pi 3 and got the same result!
Output:

[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 0 with SSID ""
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 1 with SSID ""
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 2 with SSID ""
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 3 with SSID ""
[ INFO ] DietPi-WiFiDB | Applied WiFi DB slot 4 with SSID ""
[ SUB1 ] DietPi-Services > stop
[  OK  ] DietPi-Services | stop : cron
[ SUB1 ] DietPi-Set_hardware > wifimodules (disable)
[  OK  ] DietPi-Set_hardware | Desired setting in /boot/config.txt was already set: dtoverlay=disable-wifi
[  OK  ] wifimodules disable | Completed
[  OK  ] DietPi-Config | Dropping connections, please wait...
RTNETLINK answers: No such process

And /etc/resolv.conf had these values. But I flashed the drive and tried again.

nameserver 8.8.8.8
nameserver 8.8.4.4

2nd try

I tried to change it manually but no progress goes back to even if I remove and wrote it back:

domain lan
search lan
nameserver 192.168.1.1

I edited the /etc/network/interfaces and changed the dns-nameservers, and on the interface got this after the change:


β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€ DietPi-Config β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚ Ethernet Details:                                                            β”‚
β”‚ Usage   : Sent = 0 MiB | Recieved = 0 MiB                                    β”‚
β”‚ Address : IP = 192.168.1.218 | Mask = 255.255.255.0 | Gateway = 192.168.1.1  β”‚
β”‚ | DNS = 192.168.1.1                                                          β”‚
β”‚                                                                              β”‚
β”‚                          ●─ DHCP/STATIC IP ──────────────────────●           β”‚
β”‚           Change Mode    : [STATIC]                                          β”‚
β”‚           Copy           : Copy current address to "Static"                  β”‚
β”‚           Static IP      : [192.168.0.100]                                   β”‚
β”‚           Static Mask    : [255.255.255.0]                                   β”‚
β”‚           Static Gateway : [192.168.0.1]                                     β”‚
β”‚           Static DNS     : [8.8.8.8 8.8.4.4]                                 β”‚
β”‚                          ●─ Additional Options ──────────────────●           β”‚
β”‚           Link Speed     : [auto (default)]                                  β”‚
β”‚           Disable        : Disable Ethernet adapter                          β”‚
β”‚                          ●─ Apply ───────────────────────────────●           β”‚
β”‚           Apply          : Save all changes and restart networking           β”‚
β”‚                                                                              β”‚
β”‚                                                                              β”‚
β”‚                     <Ok>                         <Back>                      β”‚
β”‚                                                                              β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

but /etc/resolv.conf this has this info:

domain lan
search lan
nameserver 192.168.1.1

Don’t know if it changes the dns or is just a visual change.

Try the following and post the output:
ip -4 ad; ip -4 ro; nslookup dietpi.com 192.168.0.1; nslookup dietpi.com 192.168.1.1; nslookup dietpi.com 8.8.8.8; ping -c 4 8.8.8.8

Fresh image

root@DietPi:~# ip -4 ad; ip -4 ro; nslookup dietpi.com 192.168.0.1; nslookup dietpi.com 192.168.1.1; nslookup dietpi.com 8.8.8.8; ping -c 4 8.8.8.8
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 192.168.1.218/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 3262sec preferred_lft 3262sec
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.218
-bash: nslookup: command not found
-bash: nslookup: command not found
-bash: nslookup: command not found
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=60 time=16.4 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=60 time=16.3 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=60 time=16.1 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=60 time=16.4 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3005ms
rtt min/avg/max/mdev = 16.108/16.310/16.443/0.132 ms

It pings!

This is DHCP or STATIC? I guess DHCP right?

That can be an issue.
Is there host or dig ?

nslookup should not be installed by default. It can be installed using apt install dnsutils

1 Like
root@DietPi:~# ip -4 ad; ip -4 ro; nslookup dietpi.com 192.168.0.1; nslookup dietpi.com 192.168.1.1; nslookup dietpi.com 8.8.8.8; ping -c 4 8.8.8.8
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
    inet 192.168.1.218/24 brd 192.168.1.255 scope global dynamic eth0
       valid_lft 3372sec preferred_lft 3372sec
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.218
;; connection timed out; no servers could be reached


Server:         192.168.1.1
Address:        192.168.1.1#53

Non-authoritative answer:
Name:   dietpi.com
Address: 172.67.170.219
Name:   dietpi.com
Address: 104.21.28.141
Name:   dietpi.com
Address: 2606:4700:3030::6815:1c8d
Name:   dietpi.com
Address: 2606:4700:3032::ac43:aadb

Server:         8.8.8.8
Address:        8.8.8.8#53

Non-authoritative answer:
Name:   dietpi.com
Address: 188.114.97.5
Name:   dietpi.com
Address: 188.114.96.5
Name:   dietpi.com
Address: 2a06:98c1:3120::5
Name:   dietpi.com
Address: 2a06:98c1:3121::5

PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=60 time=15.8 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=60 time=16.1 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=60 time=16.1 ms
64 bytes from 8.8.8.8: icmp_seq=4 ttl=60 time=16.4 ms

--- 8.8.8.8 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3004ms
rtt min/avg/max/mdev = 15.770/16.107/16.445/0.239 ms

root@DietPi:~# dig 8.8.8.8

; <<>> DiG 9.16.27-Debian <<>> 8.8.8.8
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NXDOMAIN, id: 36926
;; flags: qr rd ra; QUERY: 1, ANSWER: 0, AUTHORITY: 1, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;8.8.8.8.                       IN      A

;; AUTHORITY SECTION:
.                       1116    IN      SOA     a.root-servers.net. nstld.verisign-grs.com. 2022091800 1800 900 604800 86400

;; Query time: 11 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sun Sep 18 11:45:48 BST 2022
;; MSG SIZE  rcvd: 111
root@DietPi:~# host 8.8.8.8
8.8.8.8.in-addr.arpa domain name pointer dns.google.

Alright, it works fine now.
Either edit the /etc/network/interfaces or use dietpi-config, just keep in mind that the second will overwrite the first. It would be safer option to use DHCP though if you are not sure what to use. However the gateway and dns is 192.168.1.1 which should be your ISP router.

Thank you all. I only use DHCP. So changing the /etc/network/interfaces it will update the DNS and ignores /etc/resolv.conf ?
I’m asking this because it doesn’t took effect. I ping to 1337x.to and I get blocked by ISP because I’m using their DNS. If I change to another DNS it bypasses the block. I have in multiple devices with the google DNS and its working.

root@DietPi:~# dig 1337x.to

; <<>> DiG 9.16.27-Debian <<>> 1337x.to
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 48831
;; flags: qr rd ra; QUERY: 1, ANSWER: 4, AUTHORITY: 3, ADDITIONAL: 19

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 4096
;; QUESTION SECTION:
;1337x.to.                      IN      A

;; ANSWER SECTION:
1337x.to.               3       IN      CNAME   1337x.to.legal.vodafone.pt.
1337x.to.legal.vodafone.pt. 86  IN      CNAME   legal.vodafone.pt.
legal.vodafone.pt.      18      IN      CNAME   kju8m5a.impervadns.net.
kju8m5a.impervadns.net. 30      IN      A       45.60.74.62

;; AUTHORITY SECTION:
impervadns.net.         3709    IN      NS      ns1.impervadns.net.
impervadns.net.         3709    IN      NS      ns3.impervadns.net.
impervadns.net.         3709    IN      NS      ns2.impervadns.net.

;; ADDITIONAL SECTION:
ns1.impervadns.net.     2905    IN      A       198.143.61.164
ns1.impervadns.net.     2905    IN      A       198.143.61.165
ns1.impervadns.net.     2905    IN      A       198.143.61.166
ns1.impervadns.net.     2905    IN      A       198.143.61.64
ns1.impervadns.net.     2905    IN      A       198.143.61.65
ns1.impervadns.net.     2905    IN      A       198.143.61.66
ns2.impervadns.net.     2905    IN      A       198.143.62.165
ns2.impervadns.net.     2905    IN      A       198.143.62.166
ns2.impervadns.net.     2905    IN      A       198.143.62.64
ns2.impervadns.net.     2905    IN      A       198.143.62.65
ns2.impervadns.net.     2905    IN      A       198.143.62.66
ns2.impervadns.net.     2905    IN      A       198.143.62.164
ns3.impervadns.net.     1240    IN      A       198.143.63.165
ns3.impervadns.net.     1240    IN      A       198.143.63.166
ns3.impervadns.net.     1240    IN      A       198.143.63.64
ns3.impervadns.net.     1240    IN      A       198.143.63.65
ns3.impervadns.net.     1240    IN      A       198.143.63.66
ns3.impervadns.net.     1240    IN      A       198.143.63.164

;; Query time: 16 msec
;; SERVER: 192.168.1.1#53(192.168.1.1)
;; WHEN: Sun Sep 18 12:33:13 BST 2022
;; MSG SIZE  rcvd: 485

This is your issue. DNS Server settings will be provided by your DHCP server. Changing them manually on the system will not have any effect. You would need to switch to STATIC IP to be able to set own DNS server on your system.

You are getting this error because when you are setting up the static IP configuration, you are specifying a gateway that is on a different subnet:

This basically kicks you off the network. If you want to use this configuration option for setting the DNS servers, you need to change the other network options as well (Static IP and Static Gateway IP) because the default settings are not correct.

An easy way to do this is to use the β€œcopy” function to set the values you already have as the values used in your new static configuration. Otherwise just change them manually.

I agree with Joulinar, if possible the best way to set the DNS server for your network is on the gateway (I’m assuming your gateway is the DHCP server). Log in to your router admin portal and change the DNS server there. This has the additional benefit of setting the nameserver you prefer on any other devices connected to your network.

If you want to change the DNS server on only the DietPi system, or changing the nameserver on the gateway is not possible or otherwise undesirable, you can go ahead with setting the static IP configuration as you are doing–but you should still log in to your router’s admin portal to set a DHCP reservation for the DietPi’s IP address to ensure you don’t run into an address conflict down the road.

1 Like

Thank you for your help! And sorry! :laughing: