DNS resolve not working can you please advice.

au190

New Member
Credits
113
Hi Iam new on linux, but i would like to know more about.

I have a linux server, docker on it. I would like to use PiHole, but as the linux has its own systemd-resolved.service DNS resolver, I can not start the pihole on the same port 53.

I tryed to diasble this service, but the problem is then the DNS resolve is not working.
# sudo systemctl disable systemd-resolved.service
# sudo systemctl stop systemd-resolved.service

My question is why the linux is not getting the DNS name form my router with DHCP config ?

I tryed to setup my network config, but the DNS still not working. Can you please advice ?

Code:
[email protected]:~# nano /etc/netplan/00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
  ethernets:
    eno1:
      dhcp4: true
      gateway4: 192.168.2.1
      nameservers:
        addresses: [8.8.8.8]
  version: 2

Thx for your help.
 


f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
If you use dhcp your system should get the ip address, gateway and dns from your router. You also have gateway setup and nameserver which you only need to configure manually when using static ip configuration. I don't use netplan but I think it should look more something like this.
Code:
network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: true
Then afterwards run
Code:
sudo netplan apply
Otherwise reboot your system, after that it should automatically get network configuration from your router if your router is setup to use dhcp.
 
Last edited:

Rob

Administrator
Staff member
Credits
129
I had to disable systemd-resolved on some redis servers we were setting up. I don't recall how we did it, but here's a solution:

 

au190

New Member
Credits
113
Thx, for the above response. But it looks like Iam not doing something properly .....

I don't know what Iam doing wrong .... can you please help me ?
After reboot same can not ping the name.

Code:
[email protected]:~# ping google.com
PING google.com (172.217.20.14) 56(84) bytes of data.
64 bytes from ham02s13-in-f14.1e100.net (172.217.20.14): icmp_seq=1 ttl=117 time=3.64 ms
64 bytes from ham02s13-in-f14.1e100.net (172.217.20.14): icmp_seq=2 ttl=117 time=3.36 ms

[email protected]:~# nano /etc/systemd/resolved.conf
[email protected]:~# systemctl stop systemd-resolved
[email protected]:~# sudo systemctl disable systemd-resolved.service
Removed /etc/systemd/system/multi-user.target.wants/systemd-resolved.service.
Removed /etc/systemd/system/dbus-org.freedesktop.resolve1.service.
[email protected]:~#

[email protected]:~# rm /etc/resolv.conf
[email protected]:~# cat /etc/systemd/resolved.conf
#  This file is part of systemd.
#
#  systemd is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
# Entries in this file show the compile time defaults.
# You can change settings by editing this file.
# Defaults can be restored by simply deleting this file.
#
# See resolved.conf(5) for details

[Resolve]
#DNS=
#FallbackDNS=
#Domains=
#LLMNR=no
#MulticastDNS=no
#DNSSEC=no
#DNSOverTLS=no
#Cache=yes
#DNSStubListener=no
#ReadEtcHosts=yes
[email protected]:~#

[email protected]:~# ping google.com
ping: google.com: Temporary failure in name resolution

[email protected]:~# cat /etc/netplan/00-installer-config.yaml
# This is the network config written by 'subiquity'
#network:
#  ethernets:
#    eno1:
#      dhcp4: true
#  version: 2

network:
  version: 2
  renderer: networkd
  ethernets:
    eno1:
      dhcp4: no
      dhcp6: no
      addresses: [192.168.2.190/24]
      gateway4: 192.168.2.1
      nameservers:
        addresses: [8.8.8.8,8.8.4.4]
       
[email protected]:~# sudo netplan apply

[email protected]:~#
[email protected]:~# ping google.com
ping: google.com: Temporary failure in name resolution
[email protected]:~#
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
Try this instead
Code:
network:
  version: 2
  renderer: NetworkManager 
  ethernets:
     eno1:
       dhcp4: true
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
Also if you put a # in the beginning of line it means the line is a comment and it will be ignored. So remove the the # from the lines that you want your active network configuration to be.
 

au190

New Member
Credits
113
Also if you put a # in the beginning of line it means the line is a comment and it will be ignored. So remove the the # from the lines that you want your active network configuration to be.

Yes I know the # is a comment- I just want a very simple configuraation when the server has dynamic IP form router, and the DNS resolve ip set manualy or form router.

I tryed all these config, but I dont know why its not working.
The DNS resovle ist working olny if I start the service: systemd-resolved.service - but I do not wnat to use that.
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
Can you open a terminal and show me the output of:
Code:
systemctl list-unit-files | grep -i network
 

au190

New Member
Credits
113
Can you open a terminal and show me the output of:
Code:
systemctl list-unit-files | grep -i network
update the config to have ip:
sudo nano /etc/netplan/00-installer-config.yaml

# This is the network config written by 'subiquity'
network:
ethernets:
eno1:
dhcp4: true
version: 2



$ systemctl list-unit-files | grep -i network

network-manager.service generated enabled
networkd-dispatcher.service enabled enabled
NetworkManager-dispatcher.service masked enabled
NetworkManager-wait-online.service masked enabled
NetworkManager.service masked enabled
systemd-network-generator.service disabled enabled
systemd-networkd-wait-online.service enabled enabled
systemd-networkd.service enabled enabled
systemd-networkd.socket enabled enabled
network-online.target static enabled
network-pre.target static disabled
network.target static disabled
 
Last edited:

au190

New Member
Credits
113
~# ip route show

default via 192.168.2.1 dev eno1 proto dhcp src 192.168.2.190 metric 100
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.18.0.0/16 dev br-502b68904b87 proto kernel scope link src 172.18.0.1
172.19.0.0/16 dev br-39bca8306760 proto kernel scope link src 172.19.0.1
192.168.2.0/24 dev eno1 proto kernel scope link src 192.168.2.190
192.168.2.1 dev eno1 proto dhcp scope link src 192.168.2.190 metric 100
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
I found somewhat of a workaround for you.
1. systemctl disable NetworkManager systemd-resolved.service
2. systemctl enable systemd-networkd.service
3. create a file with the following name: /etc/systemd/network/20-lan.network with the following contents
[Match]
Name=eno1

[Network]
DHCP=yes
4. rm /etc/resolv.conf
5. Then create a file with the name of the one you just removed: /etc/resolv.conf with the following content
nameserver 1.1.1.1
nameserver 9.9.9.9
Replacing the ip addresses with the ip addresses of the dns servers you want to use.
6. reboot your system.

Now you have nothing running on port 53 and you are able to do use dns.
 
Last edited:

au190

New Member
Credits
113
I found somewhat of a workaround for you.
1. systemctl disable NetworkManager systemd-resolved.service
2. systemctl enable systemd-networkd.service
3. create a file with the following name: /etc/systemd/network/20-lan.network with the following contents

4. rm /etc/resolv.conf
5. Then create a file with the name of the one you just removed: /etc/resolv.conf with the following content

Replacing the ip addresses with the ip addresses of the dns servers you want to use.
6. reboot your system.

Now you have nothing running on port 53 and you are able to do use dns.

Code:
~# systemctl disable NetworkManager systemd-resolved.service
Unit /etc/systemd/system/NetworkManager.service is masked, ignoring.
[email protected]:~#



:~# cat /etc/systemd/network/20-lan.network
[Match]
Name=eno1

[Network]
DHCP=yes
[email protected]:~#

:~# rm /etc/resolv.conf
rm: cannot remove '/etc/resolv.conf': No such file or directory
[email protected]:~#


:~# cat /etc/resolv.conf
nameserver 8.8.8.8
nameserver 8.8.4.4
[email protected]:~#


Thank you for your great work, I could not resolve this alone.
I could start PiHole container on the same Ubuntu 20 server.

This is wokring for local server perfectly. On this server I have docker containers. Those are not working properly in this way. Before stoping the systemd-resolved.service all the containers were working properly.

I have a proxy manager docker and other docker conatiners on the same server. When I try to use in browser the xxx.duckdns.org domain it can not load. The ping is ok for xxx.duckdns.org.

Mybe some other network problem for docker network. I tryed to rebulid all the contaioner but same issue.
If you can advice...
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
I got docker running on of my test machine and have the same setup I advised you.
Code:
[email protected]:~# lsb_release -cr
Release:    20.04
Codename:    focal
[email protected]:~# host linux.org
linux.org has address 172.67.153.210
Then I started the pi-hole as a docker container and then I entered my container's shell.
Code:
[email protected]:~# docker exec -it 5db181b30328 bash
[email protected]:/# host linux.org
linux.org has address 172.67.153.210
So the dns works in my pi-hole container. Is dns working in your pi-hole docker container but not in the other containers?
 
Last edited:

f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
Running on that same machine with a Centos container:
Code:
[[email protected] /]# cat /etc/redhat-release
CentOS Linux release 8.2.2004 (Core)
[[email protected] /]# host linux.org
linux.org has address 172.67.153.210

[[email protected] /]# ping -c3 linux.org
PING linux.org (104.27.166.219) 56(84) bytes of data.
64 bytes from 104.27.166.219 (104.27.166.219): icmp_seq=1 ttl=48 time=21.9 ms
64 bytes from 104.27.166.219 (104.27.166.219): icmp_seq=2 ttl=48 time=22.8 ms
64 bytes from 104.27.166.219 (104.27.166.219): icmp_seq=3 ttl=48 time=22.7 ms
And from an Ubuntu container:
Code:
[email protected]:/# lsb_release -cr
Release:    20.04
Codename:    focal

[email protected]:/# host linux.org
linux.org has address 104.27.167.219

[email protected]:/# ping -c3 linux.org
PING linux.org (104.27.167.219) 56(84) bytes of data.
64 bytes from 104.27.167.219 (104.27.167.219): icmp_seq=1 ttl=48 time=22.6 ms
64 bytes from 104.27.167.219 (104.27.167.219): icmp_seq=2 ttl=48 time=22.1 ms
64 bytes from 104.27.167.219 (104.27.167.219): icmp_seq=3 ttl=48 time=21.7 ms
 
Last edited:

au190

New Member
Credits
113
The ping is working from all the containers - but when I run a domain name from my bowser its not. With local ip its working form browser.
I can see this in the browser console:
Code:
Failed to load resource: the server responded with a status of 404 (Not Found)

I think is some network issue because I have reverse proxy.
 

f33dm3bits

Gold Member
Gold Supporter
Credits
7,600
This is wokring for local server perfectly. On this server I have docker containers. Those are not working properly in this way. Before stoping the systemd-resolved.service all the containers were working properly.

I have a proxy manager docker and other docker conatiners on the same server. When I try to use in browser the xxx.duckdns.org domain it can not load. The ping is ok for xxx.duckdns.org.

Mybe some other network problem for docker network. I tryed to rebulid all the contaioner but same issue.
If you can advice...
Can you explain a bit how you have this proxy manager docker setup, this way I can try it out on my test machine so it will be easier to see what is happening.
 

au190

New Member
Credits
113
I have port 443 open and different subdomanin forwarded internally to different prots.

Router(443 port) - Linux server - docker (revers proxy) - other docker conatiners.


Code:
:~# ip a
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eno1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc fq_codel state UP group default qlen 1000
    link/ether 14:19:1e:11:11:11 brd ff:ff:ff:ff:ff:ff
    inet 192.168.2.190/24 brd 192.168.2.255 scope global eno1
       valid_lft forever preferred_lft forever
    inet6 fe80::8639:beff:fe12:12ba/64 scope link
       valid_lft forever preferred_lft forever
3: wlp3s0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
    link/ether 38:de:a1:31:a1:c3 brd ff:ff:ff:ff:ff:ff
4: br-9ff20bd7b659: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:9a:4c:c0:c8 brd ff:ff:ff:ff:ff:ff
    inet 172.19.0.1/16 brd 172.19.255.255 scope global br-9ff20bd7b659
       valid_lft forever preferred_lft forever
    inet6 fe80::42:9aff:fe4c:c0c8/64 scope link
       valid_lft forever preferred_lft forever
5: br-b6fd70f1e5d1: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
    link/ether 02:42:02:ff:3c:7e brd ff:ff:ff:ff:ff:ff
    inet 172.18.0.1/16 brd 172.18.255.255 scope global br-b6fd70f1e5d1
       valid_lft forever preferred_lft forever
    inet6 fe80::42:2ff:feff:3c7e/64 scope link
       valid_lft forever preferred_lft forever
6: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN group default
    link/ether 02:42:58:1c:63:54 brd ff:ff:ff:ff:ff:ff
    inet 172.17.0.1/16 brd 172.17.255.255 scope global docker0
       valid_lft forever preferred_lft forever
8: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-b6fd70f1e5d1 state UP group default
    link/ether 3a:cf:f9:48:4b:41 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet6 fe80::38cf:f9ff:fe48:4b41/64 scope link
       valid_lft forever preferred_lft forever
10: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-9ff20bd7b659 state UP group default
    link/ether ce:9c:83:bd:3a:b4 brd ff:ff:ff:ff:ff:ff link-netnsid 1
    inet6 fe80::cc9c:83ff:febd:3ab4/64 scope link
       valid_lft forever preferred_lft forever
12: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-b6fd70f1e5d1 state UP group default
    link/ether e2:52:e3:8f:d0:a6 brd ff:ff:ff:ff:ff:ff link-netnsid 3
    inet6 fe80::e052:e3ff:fe8f:d0a6/64 scope link
       valid_lft forever preferred_lft forever
14: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-b6fd70f1e5d1 state UP group default
    link/ether 2a:eb:15:24:e5:4b brd ff:ff:ff:ff:ff:ff link-netnsid 6
    inet6 fe80::28eb:15ff:fe24:e54b/64 scope link
       valid_lft forever preferred_lft forever
16: vethefe1[email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-b6fd70f1e5d1 state UP group default
    link/ether ca:50:2c:5d:14:cb brd ff:ff:ff:ff:ff:ff link-netnsid 4
    inet6 fe80::c850:2cff:fe5d:14cb/64 scope link
       valid_lft forever preferred_lft forever
18: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-b6fd70f1e5d1 state UP group default
    link/ether 62:ce:e6:7f:25:a8 brd ff:ff:ff:ff:ff:ff link-netnsid 2
    inet6 fe80::60ce:e6ff:fe7f:25a8/64 scope link
       valid_lft forever preferred_lft forever
20: [email protected]: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue master br-b6fd70f1e5d1 state UP group default
    link/ether 32:e0:29:52:ce:9e brd ff:ff:ff:ff:ff:ff link-netnsid 5
    inet6 fe80::30e0:29ff:fe52:ce9e/64 scope link
       valid_lft forever preferred_lft forever
 

au190

New Member
Credits
113
~# ip route
default via 192.168.2.1 dev eno1 proto dhcp src 192.168.2.190 metric 100
172.17.0.0/16 dev docker0 proto kernel scope link src 172.17.0.1 linkdown
172.18.0.0/16 dev br-b6fd70f1e5d1 proto kernel scope link src 172.18.0.1
172.19.0.0/16 dev br-9ff20bd7b659 proto kernel scope link src 172.19.0.1
192.168.2.0/24 dev eno1 proto kernel scope link src 192.168.2.190
192.168.2.1 dev eno1 proto dhcp scope link src 192.168.2.190 metric 100
 


Members online


Latest posts

Top