0

My system has services that talks to other servers on the LAN by custom internal domain name. I have netplan setup as follows:

network:
    ethernets:
        ens160:
            addresses:
            - 192.168.12.10/24
            gateway4: 192.168.12.1
            nameservers:
                addresses: [192.168.12.1, 8.8.8.8, 8.8.4.4]
            optional: true
    version: 2

When the server starts after a reboot, it seems the 192.168.12.1 is ignored as a nameserver because the response when trying to curl -v or ajax to local services isn't from my local dns server. But if I run netplan --debug apply my output is normal and everything starts working properly again until i reboot the system.

Any idea how to fix this beyond setting a cron job to run @reboot /usr/sbin/netplan apply?

System:

  Operating System: Ubuntu 18.04.4 LTS
            Kernel: Linux 4.15.0-99-generic

netplan is assigning the right static IP on boot but not using the nameservers. The system does not have any other custom network configruations/static routes outside netplan and ufw. ufw has allow 22 and nginx full.

dig @192.168.12.1 www.ebay.com

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> @192.168.12.1 www.ebay.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 4332
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

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

;; ANSWER SECTION:
www.ebay.com.       229 IN  CNAME   slot9428.ebay.com.edgekey.net.
slot9428.ebay.com.edgekey.net. 21403 IN CNAME   e9428.b.akamaiedge.net.
e9428.b.akamaiedge.net. 20  IN  A   104.96.86.47

;; Query time: 139 msec
;; SERVER: 192.168.12.1#53(192.168.12.1)
;; WHEN: Tue May 19 14:51:43 EDT 2020
;; MSG SIZE  rcvd: 133



dig @8.8.8.8 www.ebay.com

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> @8.8.8.8 www.ebay.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 18574
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.ebay.com.          IN  A

;; ANSWER SECTION:
www.ebay.com.       117 IN  CNAME   slot9428.ebay.com.edgekey.net.
slot9428.ebay.com.edgekey.net. 19569 IN CNAME   e9428.b.akamaiedge.net.
e9428.b.akamaiedge.net. 19  IN  A   104.96.86.47

;; Query time: 27 msec
;; SERVER: 8.8.8.8#53(8.8.8.8)
;; WHEN: Tue May 19 14:52:09 EDT 2020
;; MSG SIZE  rcvd: 133



dig @8.8.4.4 www.ebay.com

; <<>> DiG 9.11.3-1ubuntu1.11-Ubuntu <<>> @8.8.4.4 www.ebay.com
; (1 server found)
;; global options: +cmd
;; Got answer:
;; ->>HEADER<<- opcode: QUERY, status: NOERROR, id: 5372
;; flags: qr rd ra; QUERY: 1, ANSWER: 3, AUTHORITY: 0, ADDITIONAL: 1

;; OPT PSEUDOSECTION:
; EDNS: version: 0, flags:; udp: 512
;; QUESTION SECTION:
;www.ebay.com.          IN  A

;; ANSWER SECTION:
www.ebay.com.       286 IN  CNAME   slot9428.ebay.com.edgekey.net.
slot9428.ebay.com.edgekey.net. 15226 IN CNAME   e9428.b.akamaiedge.net.
e9428.b.akamaiedge.net. 19  IN  A   104.96.86.47

;; Query time: 33 msec
;; SERVER: 8.8.4.4#53(8.8.4.4)
;; WHEN: Tue May 19 14:52:36 EDT 2020
;; MSG SIZE  rcvd: 133


systemd-resolve --status

Global
          DNSSEC NTA: 10.in-addr.arpa
                      16.172.in-addr.arpa
                      168.192.in-addr.arpa
                      17.172.in-addr.arpa
                      18.172.in-addr.arpa
                      19.172.in-addr.arpa
                      20.172.in-addr.arpa
                      21.172.in-addr.arpa
                      22.172.in-addr.arpa
                      23.172.in-addr.arpa
                      24.172.in-addr.arpa
                      25.172.in-addr.arpa
                      26.172.in-addr.arpa
                      27.172.in-addr.arpa
                      28.172.in-addr.arpa
                      29.172.in-addr.arpa
                      30.172.in-addr.arpa
                      31.172.in-addr.arpa
                      corp
                      d.f.ip6.arpa
                      home
                      internal
                      intranet
                      lan
                      local
                      private
                      test

Link 2 (ens160)
      Current Scopes: DNS
       LLMNR setting: yes
MulticastDNS setting: no
      DNSSEC setting: no
    DNSSEC supported: no
         DNS Servers: 192.168.12.1
                      8.8.8.8
                      8.8.4.4



cat /etc/network/interfaces
# ifupdown has been replaced by netplan(5) on this system.  See
# /etc/netplan for current configuration.
# To re-enable ifupdown on this system, you can run:
#    sudo apt install ifupdown


cat /etc/NetworkManager/NetworkManager.conf
cat: /etc/NetworkManager/NetworkManager.conf: No such file or directory



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
#Cache=yes
#DNSStubListener=yes


ls -al /etc/resolv.conf
lrwxrwxrwx 1 root root 39 Apr 26  2018 /etc/resolv.conf -> ../run/systemd/resolve/stub-resolv.conf



cat /etc/resolv.conf
# This file is managed by man:systemd-resolved(8). Do not edit.
#
# This is a dynamic resolv.conf file for connecting local clients to the
# internal DNS stub resolver of systemd-resolved. This file lists all
# configured search domains.
#
# Run "systemd-resolve --status" to see details about the uplink DNS servers
# currently in use.
#
# Third party programs must not access this file directly, but only through the
# symlink at /etc/resolv.conf. To manage man:resolv.conf(5) in a different way,
# replace this symlink by a static file or a different symlink.
#
# See man:systemd-resolved.service(8) for details about the supported modes of
# operation for /etc/resolv.conf.

nameserver 127.0.0.53
options edns0
14
  • please show the output of "ip a" when network configuration is such that the problem that you describe is present (IOW, before you run "netplan --debug apply). – leggewie May 15 '20 at 15:17
  • @MAV everyone is using the system now so I can't shut it down and reboot during the workday. I was hoping someone could shed some light on possible reasons why a system might not follow the nameservers in netplan config on system boot but will if I run netplan apply after boot. – learnsomemore May 15 '20 at 15:32
  • you don't have to provide that information right now, but then again, your question should have been complete right when you posted it. "ip a" is the very minimum and you missed it. Do you really want 100 guesswork answers? The way your question is worded, nobody can say with authority what's wrong. – leggewie May 15 '20 at 15:34
  • 1
    Also show the output of sudo systemd-resolve --status please. ResolveD actually is the one that handles DNS handoff to specified DNS servers. The /etc/resolv.conf and such doesn't change. – Thomas Ward May 15 '20 at 15:36
  • To start with, which version of Linux have you installed (Ubuntu server, Ubuntu desktop, Kubuntu, Lubuntu, Xubuntu, Ubuntu MATE, Mint, et al.) , and which release number? Different releases have different tools for us to recommend. Please click edit and add that vital information to your question so all the facts we need are in the question. Please don't use Add Comment, since that's our channel to you. All facts about your system should go in the Question with edit – K7AAY May 15 '20 at 16:37
1

netplan is very fussy about indentation, spacing, and no tabs.

Try my .yaml file...

network:
  version: 2
  renderer: networkd
  ethernets:
    ens160:
      addresses:
        - 192.168.12.10/24
      gateway4: 192.168.12.1
      nameservers:
        addresses: [192.168.12.1, 8.8.8.8, 8.8.4.4]
        search: [enter custom internal domain name]
      optional: true

sudo netplan --debug generate

sudo netplan apply

reboot

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.