Wrong nameserver set by resolvconf and NetworkManager












21















My DNS server is 192.168.1.152.



This DNS is provided to clients by DHCP. The windows clients on my LAN resolve names properly using that DNS, but my Ubuntu VM doesn't.



The VM is set up with bridge networking and is being properly provided the DNS server, but my local hostnames aren't being resolved by nslookup or browsers.



Here is an nslookup of one of my local domains:



# nslookup unraid.local
Server: 127.0.0.53
Address: 127.0.0.53#53

** server can't find unraid.local: SERVFAIL


Here is what it should resolve by using my DNS server:



# nslookup unraid.local 192.168.1.152
Server: 192.168.1.152
Address: 192.168.1.152#53

Name: unraid.local
Address: 192.168.1.152


/etc/resolv.conf has a wrong nameserver:



# Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
# DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
# 127.0.0.53 is the systemd-resolved stub resolver.
# run "systemd-resolve --status" to see details about the actual nameservers.

nameserver 127.0.0.53


I ran that command. Under DNS Servers, confusingly, it specifies the correct server (and my default gateway).



root@ubuntu:~# 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 (ens33)
Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
LLMNR setting: yes
MulticastDNS setting: no
DNSSEC setting: no
DNSSEC supported: no
DNS Servers: 192.168.1.152
192.168.1.1


I don't want to "hard code" the DNS server's IP in a config file because I won't be able to resolve when I change networks.



How can I get resolvconf and NetworkManager to automatically set the DHCP server's IP in /etc/resolv.conf?










share|improve this question





























    21















    My DNS server is 192.168.1.152.



    This DNS is provided to clients by DHCP. The windows clients on my LAN resolve names properly using that DNS, but my Ubuntu VM doesn't.



    The VM is set up with bridge networking and is being properly provided the DNS server, but my local hostnames aren't being resolved by nslookup or browsers.



    Here is an nslookup of one of my local domains:



    # nslookup unraid.local
    Server: 127.0.0.53
    Address: 127.0.0.53#53

    ** server can't find unraid.local: SERVFAIL


    Here is what it should resolve by using my DNS server:



    # nslookup unraid.local 192.168.1.152
    Server: 192.168.1.152
    Address: 192.168.1.152#53

    Name: unraid.local
    Address: 192.168.1.152


    /etc/resolv.conf has a wrong nameserver:



    # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
    # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
    # 127.0.0.53 is the systemd-resolved stub resolver.
    # run "systemd-resolve --status" to see details about the actual nameservers.

    nameserver 127.0.0.53


    I ran that command. Under DNS Servers, confusingly, it specifies the correct server (and my default gateway).



    root@ubuntu:~# 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 (ens33)
    Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
    LLMNR setting: yes
    MulticastDNS setting: no
    DNSSEC setting: no
    DNSSEC supported: no
    DNS Servers: 192.168.1.152
    192.168.1.1


    I don't want to "hard code" the DNS server's IP in a config file because I won't be able to resolve when I change networks.



    How can I get resolvconf and NetworkManager to automatically set the DHCP server's IP in /etc/resolv.conf?










    share|improve this question



























      21












      21








      21


      14






      My DNS server is 192.168.1.152.



      This DNS is provided to clients by DHCP. The windows clients on my LAN resolve names properly using that DNS, but my Ubuntu VM doesn't.



      The VM is set up with bridge networking and is being properly provided the DNS server, but my local hostnames aren't being resolved by nslookup or browsers.



      Here is an nslookup of one of my local domains:



      # nslookup unraid.local
      Server: 127.0.0.53
      Address: 127.0.0.53#53

      ** server can't find unraid.local: SERVFAIL


      Here is what it should resolve by using my DNS server:



      # nslookup unraid.local 192.168.1.152
      Server: 192.168.1.152
      Address: 192.168.1.152#53

      Name: unraid.local
      Address: 192.168.1.152


      /etc/resolv.conf has a wrong nameserver:



      # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
      # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
      # 127.0.0.53 is the systemd-resolved stub resolver.
      # run "systemd-resolve --status" to see details about the actual nameservers.

      nameserver 127.0.0.53


      I ran that command. Under DNS Servers, confusingly, it specifies the correct server (and my default gateway).



      root@ubuntu:~# 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 (ens33)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
      LLMNR setting: yes
      MulticastDNS setting: no
      DNSSEC setting: no
      DNSSEC supported: no
      DNS Servers: 192.168.1.152
      192.168.1.1


      I don't want to "hard code" the DNS server's IP in a config file because I won't be able to resolve when I change networks.



      How can I get resolvconf and NetworkManager to automatically set the DHCP server's IP in /etc/resolv.conf?










      share|improve this question
















      My DNS server is 192.168.1.152.



      This DNS is provided to clients by DHCP. The windows clients on my LAN resolve names properly using that DNS, but my Ubuntu VM doesn't.



      The VM is set up with bridge networking and is being properly provided the DNS server, but my local hostnames aren't being resolved by nslookup or browsers.



      Here is an nslookup of one of my local domains:



      # nslookup unraid.local
      Server: 127.0.0.53
      Address: 127.0.0.53#53

      ** server can't find unraid.local: SERVFAIL


      Here is what it should resolve by using my DNS server:



      # nslookup unraid.local 192.168.1.152
      Server: 192.168.1.152
      Address: 192.168.1.152#53

      Name: unraid.local
      Address: 192.168.1.152


      /etc/resolv.conf has a wrong nameserver:



      # Dynamic resolv.conf(5) file for glibc resolver(3) generated by resolvconf(8)
      # DO NOT EDIT THIS FILE BY HAND -- YOUR CHANGES WILL BE OVERWRITTEN
      # 127.0.0.53 is the systemd-resolved stub resolver.
      # run "systemd-resolve --status" to see details about the actual nameservers.

      nameserver 127.0.0.53


      I ran that command. Under DNS Servers, confusingly, it specifies the correct server (and my default gateway).



      root@ubuntu:~# 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 (ens33)
      Current Scopes: DNS LLMNR/IPv4 LLMNR/IPv6
      LLMNR setting: yes
      MulticastDNS setting: no
      DNSSEC setting: no
      DNSSEC supported: no
      DNS Servers: 192.168.1.152
      192.168.1.1


      I don't want to "hard code" the DNS server's IP in a config file because I won't be able to resolve when I change networks.



      How can I get resolvconf and NetworkManager to automatically set the DHCP server's IP in /etc/resolv.conf?







      networking dns 17.10 dhcp






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Feb 14 '18 at 21:10









      Victor

      5,88171829




      5,88171829










      asked Nov 4 '17 at 21:22









      FireSporeFireSpore

      106115




      106115






















          8 Answers
          8






          active

          oldest

          votes


















          24














          Try editing /etc/systemd/resolved.conf, adding your desired DNS server:



          change this:



          [Resolve]
          #DNS=


          to this (but use the one you want - this is an example):



          [Resolve]
          DNS=192.168.1.152


          after that, restart the service:



          service systemd-resolved restart


          And when you check the status you should see



          $ systemd-resolve --status
          Global
          DNS Servers: 192.168.1.152

          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





          share|improve this answer


























          • Here is the systemd-resolve --status after changing /etc/systemd/resolved.conf pastebin.com/AeUFQkyB Browsers still fail to resolve names also.

            – FireSpore
            Nov 4 '17 at 22:10






          • 7





            systemd is so broken. DHCP tells the host what DNS should be, (and a bunch of other network settings) you should not have to change any files on the host for this to work.

            – teknopaul
            Nov 8 '17 at 22:55






          • 2





            Does not look optimal, you will have to do this every time you change DNS server/network

            – Victor
            Feb 14 '18 at 21:23











          • You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

            – Victor
            Feb 14 '18 at 23:40



















          20














          Known systemd bug.



          Temporary workaround with no need to reconfigure if the DNS IP's changes:



          sudo rm -f /etc/resolv.conf
          sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
          reboot





          share|improve this answer





















          • 1





            This solution worked somewhat, host and nslookup commands resolve names properly, but wget and browsers are not

            – FireSpore
            Nov 11 '17 at 5:39



















          3














          I finally got a solution for this problem for ubuntu 17.10. By default this version of Ubuntu uses systemd-resolved, which I hope is going to be stable for the next versions.



          In order to use custom dns instead of the local systemd-resolved cache, do the following:




          1. add new nameservers. Edit the file in /etc/systemd/resolved.conf as sudoer. Here I've commented out the DNS entry and placed my dns

            [Resolve]
            DNS=10.96.0.10 8.8.8.8 8.8.4.4


          2. cancel the actual symlink to /etc/resolv.conf


          3. create a new symlink sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

          4. restart the service sudo service systemd-resolved restart

          5. restart the network manager sudo systemctl restart networking


          And now if you dig to a name provided by your add dns, you should see the record resolved dig nexus.default.svc.cluster.mydomain



          Last step is to update the order of resolution in /etc/nsswitch.conf, by placing the dns before the mdns4_minimal



          hosts           files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] myhostname





          share|improve this answer





















          • 1





            You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

            – Victor
            Feb 14 '18 at 23:39











          • Victor do you have a best solution? this is the same if you use static net config

            – Fabio Fumarola
            Feb 16 '18 at 15:19











          • This answer works for both static and dynamic configurations: askubuntu.com/a/974482/343617

            – Victor
            Feb 16 '18 at 15:41













          • thank you, the solution I have pointed out was static. I agree

            – Fabio Fumarola
            Feb 18 '18 at 11:39



















          1














          I put together a script that works around the issue of Netplan not currently supporting the ability to supersede DHCP supplied DNS servers and domain search order. It creates the Netplan yaml file and configures systemd-resolved to work as expected.



          ################## Start Netplan config (renderer: NetworkManager)
          # Some useful commands for customisation
          # NetConn=$(nmcli device show|grep GENERAL.CONNECTION|head -n1|awk '{print $2}')
          # IP=$(nmcli device show|grep IP4.ADDRESS|head -n1|awk '{print $2}')
          # GATEWAY=$(nmcli device show|grep IP4.GATEWAY|head -n1|awk '{print $2}')
          # sed -i 's/renderer: networkd/renderer: NetworkManager/' //etc/netplan/01-netcfg.yaml
          ######################################
          systemctl start NetworkManager
          NIC=$(nmcli device show|grep GENERAL.DEVICE|head -n1|awk '{print $2}')

          ##### create Netplan yaml config file
          cat >/etc/netplan/01-netcfg.yaml <<EOF
          # This file describes the network interfaces available on your system
          # For more information, see netplan(5).
          network:
          version: 2
          renderer: NetworkManager
          ethernets:
          EOF
          echo " ${NIC}:" >> /etc/netplan/01-netcfg.yaml
          cat >>/etc/netplan/01-netcfg.yaml <<EOF
          dhcp4: yes
          nameservers:
          search: [abc.domain.edu, def.domain.edu]
          addresses: [10.10.11.22, 10.10.11.23]

          EOF

          #work around DNS resolv bug
          systemctl stop systemd-resolved
          sed -i 's/#DNS=/DNS=10.10.11.22 10.10.11.23/' /etc/systemd/resolved.conf
          sed -i 's/#Domains=/Domains=abc.domain.edu def.domain.edu' /etc/systemd/resolved.conf
          systemctl start systemd-resolved
          systemctl restart NetworkManager
          netplan apply
          reboot
          ############### End Netplan Config





          share|improve this answer

































            1














            The solution that worked for me is posted here on my blog



            Use nano editor to edit these 2 files



            nano /etc/resolv.conf
            nano /etc/resolvconf/resolv.conf.d/head


            Add DNS servers you want to use



            nameserver 9.9.9.9
            nameserver 127.0.0.1


            Then restart the service



            service systemd-resolved restart


            Final check:



            cat /etc/resolv.conf


            Do nslookup



            nslookup google.com 


            i just used this and it fixed the problem on my laptop at home, but some time in the future when I am out of my home network I can see that it will cause problems, because the primary and secondary dns server will still be my home servers with their lan addresses.






            share|improve this answer





















            • 2





              You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

              – Victor
              Feb 14 '18 at 23:39











            • it's not elegant, but it work's gcloud sometimes sabotage my bedtime.

              – Rodrigo Ferrari
              Jun 2 '18 at 4:39











            • Editing /etc/resolv.conf doesn't work as the file will be overwritten during the systemd-resolved restart. Just edit /etc/systemd/resolved.conf. See my answer here: askubuntu.com/questions/977243/ubuntu-17-10-disable-netplan/…

              – EnzoR
              Oct 2 '18 at 16:01



















            1














            Your /etc/resolv.conf is not the problem. systemd-resolved just defaults to unconfigured, so it fails all lookups. Feel free to rant about Unconfigured vs A Reasonable Default.



            Manually add nameservers to systemd-resolved.
            (editing per Olorin's comment below to add mkdir, correct path /etc not /lib, in order to survive system updates)



            sudo mkdir -p /etc/systemd/resolved.conf.d
            sudo nano /etc/systemd/resolved.conf.d/00-my-dns-server-is.conf


            Add:



            [Resolved]
            Cache=yes
            DNS=192.168.1.152


            Then...



            sudo systemctl daemon-reload


            systemd-resolved is smart, but, unconfigured as it is, by package maintainers, it just LOOKS stupid because package maintainers do not believe in A Reasonable Default. We can put 13 internet root servers in there aka "djb way", or 10 opennic servers: https://pastebin.com/JBfYVVtG or the three fastest opennic servers, as measured by namebench. Plus ISP nameservers, sure. Plus Google, sure. systemd-resolved is not the problem. I am the problem.






            share|improve this answer


























            • Though you probably don't want to edit a file /usr/lib - those will likely be overwritten on package upgrade. I think a corresponding file somewhere in /etc/systemd is the way to go (it already should have an /etc/systemd/resolved.conf ready to be edited by admins).

              – Olorin
              Jan 23 at 4:16






            • 1





              man resolved.conf.d, with the d, yes /etc/systemd/resolved.d is the place. I'm noticing that we often have to mkdir /etc/[path].d. bob@laptop l /etc/systemd/resolved.conf.d ls: cannot access '/etc/systemd/resolved.conf.d': No such file or directory

              – BobDodds
              Jan 23 at 4:20





















            0














            On my system I found a bad symlink: /etc/resolv.conf was a symlink which points to /run/systemd/resolve/stub-resolv.conf



            This file contains only one line:



            nameserver 127.0.0.53#53


            As a result, the local network's DNS lookup was often missing.



            So, instead I changed /etc/reolv.conf to point to /run/systemd/resolve/resolv.conf



            and now works correctly.






            share|improve this answer

































              -3














              I have the same problem. Each reboot, nothing will resolve. I've uninstalled everything and reinstalled it about 50 times already. It's simply just broken.



              so the fix is.... "just apply a few settings each time you boot your pc, which allows 90% of host names to resolve but wget and apt-get updates and upgrades will fail randomly for no reason"



              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=yes
              #MulticastDNS=yes
              #DNSSEC=no
              #Cache=yes
              #DNSStubListener=udp


              When using Ubuntu 17.10 Desktop, you have to edit the one file that says DO NOT EDIT THIS FILE BLAH BLAH BLAH



              well that's the ONLY way it works~!



              root@nas:~# cat /etc/resolv.conf
              # This file is managed by man:systemd-resolved(8). Do not edit.
              #
              # 127.0.0.53 is the systemd-resolved stub resolver.
              # run "systemd-resolve --status" to see details about the actual nameservers.
              nameserver 8.8.8.8


              So remove the 127.0.0.53 IP as the name server and enter another one, google for example. It appears my actual DNS IP address doesn't resolve host names either (even though it works on 10 other machines and devices in the house), but google's works fine.






              share|improve this answer

























                Your Answer








                StackExchange.ready(function() {
                var channelOptions = {
                tags: "".split(" "),
                id: "89"
                };
                initTagRenderer("".split(" "), "".split(" "), channelOptions);

                StackExchange.using("externalEditor", function() {
                // Have to fire editor after snippets, if snippets enabled
                if (StackExchange.settings.snippets.snippetsEnabled) {
                StackExchange.using("snippets", function() {
                createEditor();
                });
                }
                else {
                createEditor();
                }
                });

                function createEditor() {
                StackExchange.prepareEditor({
                heartbeatType: 'answer',
                autoActivateHeartbeat: false,
                convertImagesToLinks: true,
                noModals: true,
                showLowRepImageUploadWarning: true,
                reputationToPostImages: 10,
                bindNavPrevention: true,
                postfix: "",
                imageUploader: {
                brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
                contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
                allowUrls: true
                },
                onDemand: true,
                discardSelector: ".discard-answer"
                ,immediatelyShowMarkdownHelp:true
                });


                }
                });














                draft saved

                draft discarded


















                StackExchange.ready(
                function () {
                StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f973017%2fwrong-nameserver-set-by-resolvconf-and-networkmanager%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                8 Answers
                8






                active

                oldest

                votes








                8 Answers
                8






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes









                24














                Try editing /etc/systemd/resolved.conf, adding your desired DNS server:



                change this:



                [Resolve]
                #DNS=


                to this (but use the one you want - this is an example):



                [Resolve]
                DNS=192.168.1.152


                after that, restart the service:



                service systemd-resolved restart


                And when you check the status you should see



                $ systemd-resolve --status
                Global
                DNS Servers: 192.168.1.152

                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





                share|improve this answer


























                • Here is the systemd-resolve --status after changing /etc/systemd/resolved.conf pastebin.com/AeUFQkyB Browsers still fail to resolve names also.

                  – FireSpore
                  Nov 4 '17 at 22:10






                • 7





                  systemd is so broken. DHCP tells the host what DNS should be, (and a bunch of other network settings) you should not have to change any files on the host for this to work.

                  – teknopaul
                  Nov 8 '17 at 22:55






                • 2





                  Does not look optimal, you will have to do this every time you change DNS server/network

                  – Victor
                  Feb 14 '18 at 21:23











                • You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:40
















                24














                Try editing /etc/systemd/resolved.conf, adding your desired DNS server:



                change this:



                [Resolve]
                #DNS=


                to this (but use the one you want - this is an example):



                [Resolve]
                DNS=192.168.1.152


                after that, restart the service:



                service systemd-resolved restart


                And when you check the status you should see



                $ systemd-resolve --status
                Global
                DNS Servers: 192.168.1.152

                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





                share|improve this answer


























                • Here is the systemd-resolve --status after changing /etc/systemd/resolved.conf pastebin.com/AeUFQkyB Browsers still fail to resolve names also.

                  – FireSpore
                  Nov 4 '17 at 22:10






                • 7





                  systemd is so broken. DHCP tells the host what DNS should be, (and a bunch of other network settings) you should not have to change any files on the host for this to work.

                  – teknopaul
                  Nov 8 '17 at 22:55






                • 2





                  Does not look optimal, you will have to do this every time you change DNS server/network

                  – Victor
                  Feb 14 '18 at 21:23











                • You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:40














                24












                24








                24







                Try editing /etc/systemd/resolved.conf, adding your desired DNS server:



                change this:



                [Resolve]
                #DNS=


                to this (but use the one you want - this is an example):



                [Resolve]
                DNS=192.168.1.152


                after that, restart the service:



                service systemd-resolved restart


                And when you check the status you should see



                $ systemd-resolve --status
                Global
                DNS Servers: 192.168.1.152

                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





                share|improve this answer















                Try editing /etc/systemd/resolved.conf, adding your desired DNS server:



                change this:



                [Resolve]
                #DNS=


                to this (but use the one you want - this is an example):



                [Resolve]
                DNS=192.168.1.152


                after that, restart the service:



                service systemd-resolved restart


                And when you check the status you should see



                $ systemd-resolve --status
                Global
                DNS Servers: 192.168.1.152

                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






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Dec 7 '17 at 15:11









                Zanna

                50.6k13136241




                50.6k13136241










                answered Nov 4 '17 at 22:02









                Leandro NoskoskiLeandro Noskoski

                34913




                34913













                • Here is the systemd-resolve --status after changing /etc/systemd/resolved.conf pastebin.com/AeUFQkyB Browsers still fail to resolve names also.

                  – FireSpore
                  Nov 4 '17 at 22:10






                • 7





                  systemd is so broken. DHCP tells the host what DNS should be, (and a bunch of other network settings) you should not have to change any files on the host for this to work.

                  – teknopaul
                  Nov 8 '17 at 22:55






                • 2





                  Does not look optimal, you will have to do this every time you change DNS server/network

                  – Victor
                  Feb 14 '18 at 21:23











                • You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:40



















                • Here is the systemd-resolve --status after changing /etc/systemd/resolved.conf pastebin.com/AeUFQkyB Browsers still fail to resolve names also.

                  – FireSpore
                  Nov 4 '17 at 22:10






                • 7





                  systemd is so broken. DHCP tells the host what DNS should be, (and a bunch of other network settings) you should not have to change any files on the host for this to work.

                  – teknopaul
                  Nov 8 '17 at 22:55






                • 2





                  Does not look optimal, you will have to do this every time you change DNS server/network

                  – Victor
                  Feb 14 '18 at 21:23











                • You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:40

















                Here is the systemd-resolve --status after changing /etc/systemd/resolved.conf pastebin.com/AeUFQkyB Browsers still fail to resolve names also.

                – FireSpore
                Nov 4 '17 at 22:10





                Here is the systemd-resolve --status after changing /etc/systemd/resolved.conf pastebin.com/AeUFQkyB Browsers still fail to resolve names also.

                – FireSpore
                Nov 4 '17 at 22:10




                7




                7





                systemd is so broken. DHCP tells the host what DNS should be, (and a bunch of other network settings) you should not have to change any files on the host for this to work.

                – teknopaul
                Nov 8 '17 at 22:55





                systemd is so broken. DHCP tells the host what DNS should be, (and a bunch of other network settings) you should not have to change any files on the host for this to work.

                – teknopaul
                Nov 8 '17 at 22:55




                2




                2





                Does not look optimal, you will have to do this every time you change DNS server/network

                – Victor
                Feb 14 '18 at 21:23





                Does not look optimal, you will have to do this every time you change DNS server/network

                – Victor
                Feb 14 '18 at 21:23













                You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                – Victor
                Feb 14 '18 at 23:40





                You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                – Victor
                Feb 14 '18 at 23:40













                20














                Known systemd bug.



                Temporary workaround with no need to reconfigure if the DNS IP's changes:



                sudo rm -f /etc/resolv.conf
                sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
                reboot





                share|improve this answer





















                • 1





                  This solution worked somewhat, host and nslookup commands resolve names properly, but wget and browsers are not

                  – FireSpore
                  Nov 11 '17 at 5:39
















                20














                Known systemd bug.



                Temporary workaround with no need to reconfigure if the DNS IP's changes:



                sudo rm -f /etc/resolv.conf
                sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
                reboot





                share|improve this answer





















                • 1





                  This solution worked somewhat, host and nslookup commands resolve names properly, but wget and browsers are not

                  – FireSpore
                  Nov 11 '17 at 5:39














                20












                20








                20







                Known systemd bug.



                Temporary workaround with no need to reconfigure if the DNS IP's changes:



                sudo rm -f /etc/resolv.conf
                sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
                reboot





                share|improve this answer















                Known systemd bug.



                Temporary workaround with no need to reconfigure if the DNS IP's changes:



                sudo rm -f /etc/resolv.conf
                sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf
                reboot






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Feb 14 '18 at 23:37









                Victor

                5,88171829




                5,88171829










                answered Nov 8 '17 at 22:53









                teknopaulteknopaul

                88669




                88669








                • 1





                  This solution worked somewhat, host and nslookup commands resolve names properly, but wget and browsers are not

                  – FireSpore
                  Nov 11 '17 at 5:39














                • 1





                  This solution worked somewhat, host and nslookup commands resolve names properly, but wget and browsers are not

                  – FireSpore
                  Nov 11 '17 at 5:39








                1




                1





                This solution worked somewhat, host and nslookup commands resolve names properly, but wget and browsers are not

                – FireSpore
                Nov 11 '17 at 5:39





                This solution worked somewhat, host and nslookup commands resolve names properly, but wget and browsers are not

                – FireSpore
                Nov 11 '17 at 5:39











                3














                I finally got a solution for this problem for ubuntu 17.10. By default this version of Ubuntu uses systemd-resolved, which I hope is going to be stable for the next versions.



                In order to use custom dns instead of the local systemd-resolved cache, do the following:




                1. add new nameservers. Edit the file in /etc/systemd/resolved.conf as sudoer. Here I've commented out the DNS entry and placed my dns

                  [Resolve]
                  DNS=10.96.0.10 8.8.8.8 8.8.4.4


                2. cancel the actual symlink to /etc/resolv.conf


                3. create a new symlink sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

                4. restart the service sudo service systemd-resolved restart

                5. restart the network manager sudo systemctl restart networking


                And now if you dig to a name provided by your add dns, you should see the record resolved dig nexus.default.svc.cluster.mydomain



                Last step is to update the order of resolution in /etc/nsswitch.conf, by placing the dns before the mdns4_minimal



                hosts           files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] myhostname





                share|improve this answer





















                • 1





                  You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:39











                • Victor do you have a best solution? this is the same if you use static net config

                  – Fabio Fumarola
                  Feb 16 '18 at 15:19











                • This answer works for both static and dynamic configurations: askubuntu.com/a/974482/343617

                  – Victor
                  Feb 16 '18 at 15:41













                • thank you, the solution I have pointed out was static. I agree

                  – Fabio Fumarola
                  Feb 18 '18 at 11:39
















                3














                I finally got a solution for this problem for ubuntu 17.10. By default this version of Ubuntu uses systemd-resolved, which I hope is going to be stable for the next versions.



                In order to use custom dns instead of the local systemd-resolved cache, do the following:




                1. add new nameservers. Edit the file in /etc/systemd/resolved.conf as sudoer. Here I've commented out the DNS entry and placed my dns

                  [Resolve]
                  DNS=10.96.0.10 8.8.8.8 8.8.4.4


                2. cancel the actual symlink to /etc/resolv.conf


                3. create a new symlink sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

                4. restart the service sudo service systemd-resolved restart

                5. restart the network manager sudo systemctl restart networking


                And now if you dig to a name provided by your add dns, you should see the record resolved dig nexus.default.svc.cluster.mydomain



                Last step is to update the order of resolution in /etc/nsswitch.conf, by placing the dns before the mdns4_minimal



                hosts           files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] myhostname





                share|improve this answer





















                • 1





                  You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:39











                • Victor do you have a best solution? this is the same if you use static net config

                  – Fabio Fumarola
                  Feb 16 '18 at 15:19











                • This answer works for both static and dynamic configurations: askubuntu.com/a/974482/343617

                  – Victor
                  Feb 16 '18 at 15:41













                • thank you, the solution I have pointed out was static. I agree

                  – Fabio Fumarola
                  Feb 18 '18 at 11:39














                3












                3








                3







                I finally got a solution for this problem for ubuntu 17.10. By default this version of Ubuntu uses systemd-resolved, which I hope is going to be stable for the next versions.



                In order to use custom dns instead of the local systemd-resolved cache, do the following:




                1. add new nameservers. Edit the file in /etc/systemd/resolved.conf as sudoer. Here I've commented out the DNS entry and placed my dns

                  [Resolve]
                  DNS=10.96.0.10 8.8.8.8 8.8.4.4


                2. cancel the actual symlink to /etc/resolv.conf


                3. create a new symlink sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

                4. restart the service sudo service systemd-resolved restart

                5. restart the network manager sudo systemctl restart networking


                And now if you dig to a name provided by your add dns, you should see the record resolved dig nexus.default.svc.cluster.mydomain



                Last step is to update the order of resolution in /etc/nsswitch.conf, by placing the dns before the mdns4_minimal



                hosts           files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] myhostname





                share|improve this answer















                I finally got a solution for this problem for ubuntu 17.10. By default this version of Ubuntu uses systemd-resolved, which I hope is going to be stable for the next versions.



                In order to use custom dns instead of the local systemd-resolved cache, do the following:




                1. add new nameservers. Edit the file in /etc/systemd/resolved.conf as sudoer. Here I've commented out the DNS entry and placed my dns

                  [Resolve]
                  DNS=10.96.0.10 8.8.8.8 8.8.4.4


                2. cancel the actual symlink to /etc/resolv.conf


                3. create a new symlink sudo ln -s /run/systemd/resolve/resolv.conf /etc/resolv.conf

                4. restart the service sudo service systemd-resolved restart

                5. restart the network manager sudo systemctl restart networking


                And now if you dig to a name provided by your add dns, you should see the record resolved dig nexus.default.svc.cluster.mydomain



                Last step is to update the order of resolution in /etc/nsswitch.conf, by placing the dns before the mdns4_minimal



                hosts           files dns mdns4_minimal [NOTFOUND=return] resolve [!UNAVAIL=return] myhostname






                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jan 30 '18 at 9:56

























                answered Jan 30 '18 at 9:50









                Fabio FumarolaFabio Fumarola

                1393




                1393








                • 1





                  You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:39











                • Victor do you have a best solution? this is the same if you use static net config

                  – Fabio Fumarola
                  Feb 16 '18 at 15:19











                • This answer works for both static and dynamic configurations: askubuntu.com/a/974482/343617

                  – Victor
                  Feb 16 '18 at 15:41













                • thank you, the solution I have pointed out was static. I agree

                  – Fabio Fumarola
                  Feb 18 '18 at 11:39














                • 1





                  You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                  – Victor
                  Feb 14 '18 at 23:39











                • Victor do you have a best solution? this is the same if you use static net config

                  – Fabio Fumarola
                  Feb 16 '18 at 15:19











                • This answer works for both static and dynamic configurations: askubuntu.com/a/974482/343617

                  – Victor
                  Feb 16 '18 at 15:41













                • thank you, the solution I have pointed out was static. I agree

                  – Fabio Fumarola
                  Feb 18 '18 at 11:39








                1




                1





                You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                – Victor
                Feb 14 '18 at 23:39





                You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                – Victor
                Feb 14 '18 at 23:39













                Victor do you have a best solution? this is the same if you use static net config

                – Fabio Fumarola
                Feb 16 '18 at 15:19





                Victor do you have a best solution? this is the same if you use static net config

                – Fabio Fumarola
                Feb 16 '18 at 15:19













                This answer works for both static and dynamic configurations: askubuntu.com/a/974482/343617

                – Victor
                Feb 16 '18 at 15:41







                This answer works for both static and dynamic configurations: askubuntu.com/a/974482/343617

                – Victor
                Feb 16 '18 at 15:41















                thank you, the solution I have pointed out was static. I agree

                – Fabio Fumarola
                Feb 18 '18 at 11:39





                thank you, the solution I have pointed out was static. I agree

                – Fabio Fumarola
                Feb 18 '18 at 11:39











                1














                I put together a script that works around the issue of Netplan not currently supporting the ability to supersede DHCP supplied DNS servers and domain search order. It creates the Netplan yaml file and configures systemd-resolved to work as expected.



                ################## Start Netplan config (renderer: NetworkManager)
                # Some useful commands for customisation
                # NetConn=$(nmcli device show|grep GENERAL.CONNECTION|head -n1|awk '{print $2}')
                # IP=$(nmcli device show|grep IP4.ADDRESS|head -n1|awk '{print $2}')
                # GATEWAY=$(nmcli device show|grep IP4.GATEWAY|head -n1|awk '{print $2}')
                # sed -i 's/renderer: networkd/renderer: NetworkManager/' //etc/netplan/01-netcfg.yaml
                ######################################
                systemctl start NetworkManager
                NIC=$(nmcli device show|grep GENERAL.DEVICE|head -n1|awk '{print $2}')

                ##### create Netplan yaml config file
                cat >/etc/netplan/01-netcfg.yaml <<EOF
                # This file describes the network interfaces available on your system
                # For more information, see netplan(5).
                network:
                version: 2
                renderer: NetworkManager
                ethernets:
                EOF
                echo " ${NIC}:" >> /etc/netplan/01-netcfg.yaml
                cat >>/etc/netplan/01-netcfg.yaml <<EOF
                dhcp4: yes
                nameservers:
                search: [abc.domain.edu, def.domain.edu]
                addresses: [10.10.11.22, 10.10.11.23]

                EOF

                #work around DNS resolv bug
                systemctl stop systemd-resolved
                sed -i 's/#DNS=/DNS=10.10.11.22 10.10.11.23/' /etc/systemd/resolved.conf
                sed -i 's/#Domains=/Domains=abc.domain.edu def.domain.edu' /etc/systemd/resolved.conf
                systemctl start systemd-resolved
                systemctl restart NetworkManager
                netplan apply
                reboot
                ############### End Netplan Config





                share|improve this answer






























                  1














                  I put together a script that works around the issue of Netplan not currently supporting the ability to supersede DHCP supplied DNS servers and domain search order. It creates the Netplan yaml file and configures systemd-resolved to work as expected.



                  ################## Start Netplan config (renderer: NetworkManager)
                  # Some useful commands for customisation
                  # NetConn=$(nmcli device show|grep GENERAL.CONNECTION|head -n1|awk '{print $2}')
                  # IP=$(nmcli device show|grep IP4.ADDRESS|head -n1|awk '{print $2}')
                  # GATEWAY=$(nmcli device show|grep IP4.GATEWAY|head -n1|awk '{print $2}')
                  # sed -i 's/renderer: networkd/renderer: NetworkManager/' //etc/netplan/01-netcfg.yaml
                  ######################################
                  systemctl start NetworkManager
                  NIC=$(nmcli device show|grep GENERAL.DEVICE|head -n1|awk '{print $2}')

                  ##### create Netplan yaml config file
                  cat >/etc/netplan/01-netcfg.yaml <<EOF
                  # This file describes the network interfaces available on your system
                  # For more information, see netplan(5).
                  network:
                  version: 2
                  renderer: NetworkManager
                  ethernets:
                  EOF
                  echo " ${NIC}:" >> /etc/netplan/01-netcfg.yaml
                  cat >>/etc/netplan/01-netcfg.yaml <<EOF
                  dhcp4: yes
                  nameservers:
                  search: [abc.domain.edu, def.domain.edu]
                  addresses: [10.10.11.22, 10.10.11.23]

                  EOF

                  #work around DNS resolv bug
                  systemctl stop systemd-resolved
                  sed -i 's/#DNS=/DNS=10.10.11.22 10.10.11.23/' /etc/systemd/resolved.conf
                  sed -i 's/#Domains=/Domains=abc.domain.edu def.domain.edu' /etc/systemd/resolved.conf
                  systemctl start systemd-resolved
                  systemctl restart NetworkManager
                  netplan apply
                  reboot
                  ############### End Netplan Config





                  share|improve this answer




























                    1












                    1








                    1







                    I put together a script that works around the issue of Netplan not currently supporting the ability to supersede DHCP supplied DNS servers and domain search order. It creates the Netplan yaml file and configures systemd-resolved to work as expected.



                    ################## Start Netplan config (renderer: NetworkManager)
                    # Some useful commands for customisation
                    # NetConn=$(nmcli device show|grep GENERAL.CONNECTION|head -n1|awk '{print $2}')
                    # IP=$(nmcli device show|grep IP4.ADDRESS|head -n1|awk '{print $2}')
                    # GATEWAY=$(nmcli device show|grep IP4.GATEWAY|head -n1|awk '{print $2}')
                    # sed -i 's/renderer: networkd/renderer: NetworkManager/' //etc/netplan/01-netcfg.yaml
                    ######################################
                    systemctl start NetworkManager
                    NIC=$(nmcli device show|grep GENERAL.DEVICE|head -n1|awk '{print $2}')

                    ##### create Netplan yaml config file
                    cat >/etc/netplan/01-netcfg.yaml <<EOF
                    # This file describes the network interfaces available on your system
                    # For more information, see netplan(5).
                    network:
                    version: 2
                    renderer: NetworkManager
                    ethernets:
                    EOF
                    echo " ${NIC}:" >> /etc/netplan/01-netcfg.yaml
                    cat >>/etc/netplan/01-netcfg.yaml <<EOF
                    dhcp4: yes
                    nameservers:
                    search: [abc.domain.edu, def.domain.edu]
                    addresses: [10.10.11.22, 10.10.11.23]

                    EOF

                    #work around DNS resolv bug
                    systemctl stop systemd-resolved
                    sed -i 's/#DNS=/DNS=10.10.11.22 10.10.11.23/' /etc/systemd/resolved.conf
                    sed -i 's/#Domains=/Domains=abc.domain.edu def.domain.edu' /etc/systemd/resolved.conf
                    systemctl start systemd-resolved
                    systemctl restart NetworkManager
                    netplan apply
                    reboot
                    ############### End Netplan Config





                    share|improve this answer















                    I put together a script that works around the issue of Netplan not currently supporting the ability to supersede DHCP supplied DNS servers and domain search order. It creates the Netplan yaml file and configures systemd-resolved to work as expected.



                    ################## Start Netplan config (renderer: NetworkManager)
                    # Some useful commands for customisation
                    # NetConn=$(nmcli device show|grep GENERAL.CONNECTION|head -n1|awk '{print $2}')
                    # IP=$(nmcli device show|grep IP4.ADDRESS|head -n1|awk '{print $2}')
                    # GATEWAY=$(nmcli device show|grep IP4.GATEWAY|head -n1|awk '{print $2}')
                    # sed -i 's/renderer: networkd/renderer: NetworkManager/' //etc/netplan/01-netcfg.yaml
                    ######################################
                    systemctl start NetworkManager
                    NIC=$(nmcli device show|grep GENERAL.DEVICE|head -n1|awk '{print $2}')

                    ##### create Netplan yaml config file
                    cat >/etc/netplan/01-netcfg.yaml <<EOF
                    # This file describes the network interfaces available on your system
                    # For more information, see netplan(5).
                    network:
                    version: 2
                    renderer: NetworkManager
                    ethernets:
                    EOF
                    echo " ${NIC}:" >> /etc/netplan/01-netcfg.yaml
                    cat >>/etc/netplan/01-netcfg.yaml <<EOF
                    dhcp4: yes
                    nameservers:
                    search: [abc.domain.edu, def.domain.edu]
                    addresses: [10.10.11.22, 10.10.11.23]

                    EOF

                    #work around DNS resolv bug
                    systemctl stop systemd-resolved
                    sed -i 's/#DNS=/DNS=10.10.11.22 10.10.11.23/' /etc/systemd/resolved.conf
                    sed -i 's/#Domains=/Domains=abc.domain.edu def.domain.edu' /etc/systemd/resolved.conf
                    systemctl start systemd-resolved
                    systemctl restart NetworkManager
                    netplan apply
                    reboot
                    ############### End Netplan Config






                    share|improve this answer














                    share|improve this answer



                    share|improve this answer








                    edited May 9 '18 at 18:26









                    Fabby

                    26.7k1360161




                    26.7k1360161










                    answered May 9 '18 at 17:19









                    WildstalkerWildstalker

                    314




                    314























                        1














                        The solution that worked for me is posted here on my blog



                        Use nano editor to edit these 2 files



                        nano /etc/resolv.conf
                        nano /etc/resolvconf/resolv.conf.d/head


                        Add DNS servers you want to use



                        nameserver 9.9.9.9
                        nameserver 127.0.0.1


                        Then restart the service



                        service systemd-resolved restart


                        Final check:



                        cat /etc/resolv.conf


                        Do nslookup



                        nslookup google.com 


                        i just used this and it fixed the problem on my laptop at home, but some time in the future when I am out of my home network I can see that it will cause problems, because the primary and secondary dns server will still be my home servers with their lan addresses.






                        share|improve this answer





















                        • 2





                          You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                          – Victor
                          Feb 14 '18 at 23:39











                        • it's not elegant, but it work's gcloud sometimes sabotage my bedtime.

                          – Rodrigo Ferrari
                          Jun 2 '18 at 4:39











                        • Editing /etc/resolv.conf doesn't work as the file will be overwritten during the systemd-resolved restart. Just edit /etc/systemd/resolved.conf. See my answer here: askubuntu.com/questions/977243/ubuntu-17-10-disable-netplan/…

                          – EnzoR
                          Oct 2 '18 at 16:01
















                        1














                        The solution that worked for me is posted here on my blog



                        Use nano editor to edit these 2 files



                        nano /etc/resolv.conf
                        nano /etc/resolvconf/resolv.conf.d/head


                        Add DNS servers you want to use



                        nameserver 9.9.9.9
                        nameserver 127.0.0.1


                        Then restart the service



                        service systemd-resolved restart


                        Final check:



                        cat /etc/resolv.conf


                        Do nslookup



                        nslookup google.com 


                        i just used this and it fixed the problem on my laptop at home, but some time in the future when I am out of my home network I can see that it will cause problems, because the primary and secondary dns server will still be my home servers with their lan addresses.






                        share|improve this answer





















                        • 2





                          You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                          – Victor
                          Feb 14 '18 at 23:39











                        • it's not elegant, but it work's gcloud sometimes sabotage my bedtime.

                          – Rodrigo Ferrari
                          Jun 2 '18 at 4:39











                        • Editing /etc/resolv.conf doesn't work as the file will be overwritten during the systemd-resolved restart. Just edit /etc/systemd/resolved.conf. See my answer here: askubuntu.com/questions/977243/ubuntu-17-10-disable-netplan/…

                          – EnzoR
                          Oct 2 '18 at 16:01














                        1












                        1








                        1







                        The solution that worked for me is posted here on my blog



                        Use nano editor to edit these 2 files



                        nano /etc/resolv.conf
                        nano /etc/resolvconf/resolv.conf.d/head


                        Add DNS servers you want to use



                        nameserver 9.9.9.9
                        nameserver 127.0.0.1


                        Then restart the service



                        service systemd-resolved restart


                        Final check:



                        cat /etc/resolv.conf


                        Do nslookup



                        nslookup google.com 


                        i just used this and it fixed the problem on my laptop at home, but some time in the future when I am out of my home network I can see that it will cause problems, because the primary and secondary dns server will still be my home servers with their lan addresses.






                        share|improve this answer















                        The solution that worked for me is posted here on my blog



                        Use nano editor to edit these 2 files



                        nano /etc/resolv.conf
                        nano /etc/resolvconf/resolv.conf.d/head


                        Add DNS servers you want to use



                        nameserver 9.9.9.9
                        nameserver 127.0.0.1


                        Then restart the service



                        service systemd-resolved restart


                        Final check:



                        cat /etc/resolv.conf


                        Do nslookup



                        nslookup google.com 


                        i just used this and it fixed the problem on my laptop at home, but some time in the future when I am out of my home network I can see that it will cause problems, because the primary and secondary dns server will still be my home servers with their lan addresses.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Aug 27 '18 at 19:10









                        honolulu lulu

                        82




                        82










                        answered Dec 7 '17 at 15:07









                        ookangzhengookangzheng

                        213




                        213








                        • 2





                          You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                          – Victor
                          Feb 14 '18 at 23:39











                        • it's not elegant, but it work's gcloud sometimes sabotage my bedtime.

                          – Rodrigo Ferrari
                          Jun 2 '18 at 4:39











                        • Editing /etc/resolv.conf doesn't work as the file will be overwritten during the systemd-resolved restart. Just edit /etc/systemd/resolved.conf. See my answer here: askubuntu.com/questions/977243/ubuntu-17-10-disable-netplan/…

                          – EnzoR
                          Oct 2 '18 at 16:01














                        • 2





                          You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                          – Victor
                          Feb 14 '18 at 23:39











                        • it's not elegant, but it work's gcloud sometimes sabotage my bedtime.

                          – Rodrigo Ferrari
                          Jun 2 '18 at 4:39











                        • Editing /etc/resolv.conf doesn't work as the file will be overwritten during the systemd-resolved restart. Just edit /etc/systemd/resolved.conf. See my answer here: askubuntu.com/questions/977243/ubuntu-17-10-disable-netplan/…

                          – EnzoR
                          Oct 2 '18 at 16:01








                        2




                        2





                        You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                        – Victor
                        Feb 14 '18 at 23:39





                        You would need to reconfigure every time the DNS IP's changes (for instance on different networks).

                        – Victor
                        Feb 14 '18 at 23:39













                        it's not elegant, but it work's gcloud sometimes sabotage my bedtime.

                        – Rodrigo Ferrari
                        Jun 2 '18 at 4:39





                        it's not elegant, but it work's gcloud sometimes sabotage my bedtime.

                        – Rodrigo Ferrari
                        Jun 2 '18 at 4:39













                        Editing /etc/resolv.conf doesn't work as the file will be overwritten during the systemd-resolved restart. Just edit /etc/systemd/resolved.conf. See my answer here: askubuntu.com/questions/977243/ubuntu-17-10-disable-netplan/…

                        – EnzoR
                        Oct 2 '18 at 16:01





                        Editing /etc/resolv.conf doesn't work as the file will be overwritten during the systemd-resolved restart. Just edit /etc/systemd/resolved.conf. See my answer here: askubuntu.com/questions/977243/ubuntu-17-10-disable-netplan/…

                        – EnzoR
                        Oct 2 '18 at 16:01











                        1














                        Your /etc/resolv.conf is not the problem. systemd-resolved just defaults to unconfigured, so it fails all lookups. Feel free to rant about Unconfigured vs A Reasonable Default.



                        Manually add nameservers to systemd-resolved.
                        (editing per Olorin's comment below to add mkdir, correct path /etc not /lib, in order to survive system updates)



                        sudo mkdir -p /etc/systemd/resolved.conf.d
                        sudo nano /etc/systemd/resolved.conf.d/00-my-dns-server-is.conf


                        Add:



                        [Resolved]
                        Cache=yes
                        DNS=192.168.1.152


                        Then...



                        sudo systemctl daemon-reload


                        systemd-resolved is smart, but, unconfigured as it is, by package maintainers, it just LOOKS stupid because package maintainers do not believe in A Reasonable Default. We can put 13 internet root servers in there aka "djb way", or 10 opennic servers: https://pastebin.com/JBfYVVtG or the three fastest opennic servers, as measured by namebench. Plus ISP nameservers, sure. Plus Google, sure. systemd-resolved is not the problem. I am the problem.






                        share|improve this answer


























                        • Though you probably don't want to edit a file /usr/lib - those will likely be overwritten on package upgrade. I think a corresponding file somewhere in /etc/systemd is the way to go (it already should have an /etc/systemd/resolved.conf ready to be edited by admins).

                          – Olorin
                          Jan 23 at 4:16






                        • 1





                          man resolved.conf.d, with the d, yes /etc/systemd/resolved.d is the place. I'm noticing that we often have to mkdir /etc/[path].d. bob@laptop l /etc/systemd/resolved.conf.d ls: cannot access '/etc/systemd/resolved.conf.d': No such file or directory

                          – BobDodds
                          Jan 23 at 4:20


















                        1














                        Your /etc/resolv.conf is not the problem. systemd-resolved just defaults to unconfigured, so it fails all lookups. Feel free to rant about Unconfigured vs A Reasonable Default.



                        Manually add nameservers to systemd-resolved.
                        (editing per Olorin's comment below to add mkdir, correct path /etc not /lib, in order to survive system updates)



                        sudo mkdir -p /etc/systemd/resolved.conf.d
                        sudo nano /etc/systemd/resolved.conf.d/00-my-dns-server-is.conf


                        Add:



                        [Resolved]
                        Cache=yes
                        DNS=192.168.1.152


                        Then...



                        sudo systemctl daemon-reload


                        systemd-resolved is smart, but, unconfigured as it is, by package maintainers, it just LOOKS stupid because package maintainers do not believe in A Reasonable Default. We can put 13 internet root servers in there aka "djb way", or 10 opennic servers: https://pastebin.com/JBfYVVtG or the three fastest opennic servers, as measured by namebench. Plus ISP nameservers, sure. Plus Google, sure. systemd-resolved is not the problem. I am the problem.






                        share|improve this answer


























                        • Though you probably don't want to edit a file /usr/lib - those will likely be overwritten on package upgrade. I think a corresponding file somewhere in /etc/systemd is the way to go (it already should have an /etc/systemd/resolved.conf ready to be edited by admins).

                          – Olorin
                          Jan 23 at 4:16






                        • 1





                          man resolved.conf.d, with the d, yes /etc/systemd/resolved.d is the place. I'm noticing that we often have to mkdir /etc/[path].d. bob@laptop l /etc/systemd/resolved.conf.d ls: cannot access '/etc/systemd/resolved.conf.d': No such file or directory

                          – BobDodds
                          Jan 23 at 4:20
















                        1












                        1








                        1







                        Your /etc/resolv.conf is not the problem. systemd-resolved just defaults to unconfigured, so it fails all lookups. Feel free to rant about Unconfigured vs A Reasonable Default.



                        Manually add nameservers to systemd-resolved.
                        (editing per Olorin's comment below to add mkdir, correct path /etc not /lib, in order to survive system updates)



                        sudo mkdir -p /etc/systemd/resolved.conf.d
                        sudo nano /etc/systemd/resolved.conf.d/00-my-dns-server-is.conf


                        Add:



                        [Resolved]
                        Cache=yes
                        DNS=192.168.1.152


                        Then...



                        sudo systemctl daemon-reload


                        systemd-resolved is smart, but, unconfigured as it is, by package maintainers, it just LOOKS stupid because package maintainers do not believe in A Reasonable Default. We can put 13 internet root servers in there aka "djb way", or 10 opennic servers: https://pastebin.com/JBfYVVtG or the three fastest opennic servers, as measured by namebench. Plus ISP nameservers, sure. Plus Google, sure. systemd-resolved is not the problem. I am the problem.






                        share|improve this answer















                        Your /etc/resolv.conf is not the problem. systemd-resolved just defaults to unconfigured, so it fails all lookups. Feel free to rant about Unconfigured vs A Reasonable Default.



                        Manually add nameservers to systemd-resolved.
                        (editing per Olorin's comment below to add mkdir, correct path /etc not /lib, in order to survive system updates)



                        sudo mkdir -p /etc/systemd/resolved.conf.d
                        sudo nano /etc/systemd/resolved.conf.d/00-my-dns-server-is.conf


                        Add:



                        [Resolved]
                        Cache=yes
                        DNS=192.168.1.152


                        Then...



                        sudo systemctl daemon-reload


                        systemd-resolved is smart, but, unconfigured as it is, by package maintainers, it just LOOKS stupid because package maintainers do not believe in A Reasonable Default. We can put 13 internet root servers in there aka "djb way", or 10 opennic servers: https://pastebin.com/JBfYVVtG or the three fastest opennic servers, as measured by namebench. Plus ISP nameservers, sure. Plus Google, sure. systemd-resolved is not the problem. I am the problem.







                        share|improve this answer














                        share|improve this answer



                        share|improve this answer








                        edited Jan 23 at 4:48

























                        answered Jan 23 at 4:11









                        BobDoddsBobDodds

                        314




                        314













                        • Though you probably don't want to edit a file /usr/lib - those will likely be overwritten on package upgrade. I think a corresponding file somewhere in /etc/systemd is the way to go (it already should have an /etc/systemd/resolved.conf ready to be edited by admins).

                          – Olorin
                          Jan 23 at 4:16






                        • 1





                          man resolved.conf.d, with the d, yes /etc/systemd/resolved.d is the place. I'm noticing that we often have to mkdir /etc/[path].d. bob@laptop l /etc/systemd/resolved.conf.d ls: cannot access '/etc/systemd/resolved.conf.d': No such file or directory

                          – BobDodds
                          Jan 23 at 4:20





















                        • Though you probably don't want to edit a file /usr/lib - those will likely be overwritten on package upgrade. I think a corresponding file somewhere in /etc/systemd is the way to go (it already should have an /etc/systemd/resolved.conf ready to be edited by admins).

                          – Olorin
                          Jan 23 at 4:16






                        • 1





                          man resolved.conf.d, with the d, yes /etc/systemd/resolved.d is the place. I'm noticing that we often have to mkdir /etc/[path].d. bob@laptop l /etc/systemd/resolved.conf.d ls: cannot access '/etc/systemd/resolved.conf.d': No such file or directory

                          – BobDodds
                          Jan 23 at 4:20



















                        Though you probably don't want to edit a file /usr/lib - those will likely be overwritten on package upgrade. I think a corresponding file somewhere in /etc/systemd is the way to go (it already should have an /etc/systemd/resolved.conf ready to be edited by admins).

                        – Olorin
                        Jan 23 at 4:16





                        Though you probably don't want to edit a file /usr/lib - those will likely be overwritten on package upgrade. I think a corresponding file somewhere in /etc/systemd is the way to go (it already should have an /etc/systemd/resolved.conf ready to be edited by admins).

                        – Olorin
                        Jan 23 at 4:16




                        1




                        1





                        man resolved.conf.d, with the d, yes /etc/systemd/resolved.d is the place. I'm noticing that we often have to mkdir /etc/[path].d. bob@laptop l /etc/systemd/resolved.conf.d ls: cannot access '/etc/systemd/resolved.conf.d': No such file or directory

                        – BobDodds
                        Jan 23 at 4:20







                        man resolved.conf.d, with the d, yes /etc/systemd/resolved.d is the place. I'm noticing that we often have to mkdir /etc/[path].d. bob@laptop l /etc/systemd/resolved.conf.d ls: cannot access '/etc/systemd/resolved.conf.d': No such file or directory

                        – BobDodds
                        Jan 23 at 4:20













                        0














                        On my system I found a bad symlink: /etc/resolv.conf was a symlink which points to /run/systemd/resolve/stub-resolv.conf



                        This file contains only one line:



                        nameserver 127.0.0.53#53


                        As a result, the local network's DNS lookup was often missing.



                        So, instead I changed /etc/reolv.conf to point to /run/systemd/resolve/resolv.conf



                        and now works correctly.






                        share|improve this answer






























                          0














                          On my system I found a bad symlink: /etc/resolv.conf was a symlink which points to /run/systemd/resolve/stub-resolv.conf



                          This file contains only one line:



                          nameserver 127.0.0.53#53


                          As a result, the local network's DNS lookup was often missing.



                          So, instead I changed /etc/reolv.conf to point to /run/systemd/resolve/resolv.conf



                          and now works correctly.






                          share|improve this answer




























                            0












                            0








                            0







                            On my system I found a bad symlink: /etc/resolv.conf was a symlink which points to /run/systemd/resolve/stub-resolv.conf



                            This file contains only one line:



                            nameserver 127.0.0.53#53


                            As a result, the local network's DNS lookup was often missing.



                            So, instead I changed /etc/reolv.conf to point to /run/systemd/resolve/resolv.conf



                            and now works correctly.






                            share|improve this answer















                            On my system I found a bad symlink: /etc/resolv.conf was a symlink which points to /run/systemd/resolve/stub-resolv.conf



                            This file contains only one line:



                            nameserver 127.0.0.53#53


                            As a result, the local network's DNS lookup was often missing.



                            So, instead I changed /etc/reolv.conf to point to /run/systemd/resolve/resolv.conf



                            and now works correctly.







                            share|improve this answer














                            share|improve this answer



                            share|improve this answer








                            edited Jan 31 at 6:24









                            Benjamin R

                            1,080816




                            1,080816










                            answered Jan 30 at 18:43









                            Bánó GáborBánó Gábor

                            1




                            1























                                -3














                                I have the same problem. Each reboot, nothing will resolve. I've uninstalled everything and reinstalled it about 50 times already. It's simply just broken.



                                so the fix is.... "just apply a few settings each time you boot your pc, which allows 90% of host names to resolve but wget and apt-get updates and upgrades will fail randomly for no reason"



                                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=yes
                                #MulticastDNS=yes
                                #DNSSEC=no
                                #Cache=yes
                                #DNSStubListener=udp


                                When using Ubuntu 17.10 Desktop, you have to edit the one file that says DO NOT EDIT THIS FILE BLAH BLAH BLAH



                                well that's the ONLY way it works~!



                                root@nas:~# cat /etc/resolv.conf
                                # This file is managed by man:systemd-resolved(8). Do not edit.
                                #
                                # 127.0.0.53 is the systemd-resolved stub resolver.
                                # run "systemd-resolve --status" to see details about the actual nameservers.
                                nameserver 8.8.8.8


                                So remove the 127.0.0.53 IP as the name server and enter another one, google for example. It appears my actual DNS IP address doesn't resolve host names either (even though it works on 10 other machines and devices in the house), but google's works fine.






                                share|improve this answer






























                                  -3














                                  I have the same problem. Each reboot, nothing will resolve. I've uninstalled everything and reinstalled it about 50 times already. It's simply just broken.



                                  so the fix is.... "just apply a few settings each time you boot your pc, which allows 90% of host names to resolve but wget and apt-get updates and upgrades will fail randomly for no reason"



                                  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=yes
                                  #MulticastDNS=yes
                                  #DNSSEC=no
                                  #Cache=yes
                                  #DNSStubListener=udp


                                  When using Ubuntu 17.10 Desktop, you have to edit the one file that says DO NOT EDIT THIS FILE BLAH BLAH BLAH



                                  well that's the ONLY way it works~!



                                  root@nas:~# cat /etc/resolv.conf
                                  # This file is managed by man:systemd-resolved(8). Do not edit.
                                  #
                                  # 127.0.0.53 is the systemd-resolved stub resolver.
                                  # run "systemd-resolve --status" to see details about the actual nameservers.
                                  nameserver 8.8.8.8


                                  So remove the 127.0.0.53 IP as the name server and enter another one, google for example. It appears my actual DNS IP address doesn't resolve host names either (even though it works on 10 other machines and devices in the house), but google's works fine.






                                  share|improve this answer




























                                    -3












                                    -3








                                    -3







                                    I have the same problem. Each reboot, nothing will resolve. I've uninstalled everything and reinstalled it about 50 times already. It's simply just broken.



                                    so the fix is.... "just apply a few settings each time you boot your pc, which allows 90% of host names to resolve but wget and apt-get updates and upgrades will fail randomly for no reason"



                                    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=yes
                                    #MulticastDNS=yes
                                    #DNSSEC=no
                                    #Cache=yes
                                    #DNSStubListener=udp


                                    When using Ubuntu 17.10 Desktop, you have to edit the one file that says DO NOT EDIT THIS FILE BLAH BLAH BLAH



                                    well that's the ONLY way it works~!



                                    root@nas:~# cat /etc/resolv.conf
                                    # This file is managed by man:systemd-resolved(8). Do not edit.
                                    #
                                    # 127.0.0.53 is the systemd-resolved stub resolver.
                                    # run "systemd-resolve --status" to see details about the actual nameservers.
                                    nameserver 8.8.8.8


                                    So remove the 127.0.0.53 IP as the name server and enter another one, google for example. It appears my actual DNS IP address doesn't resolve host names either (even though it works on 10 other machines and devices in the house), but google's works fine.






                                    share|improve this answer















                                    I have the same problem. Each reboot, nothing will resolve. I've uninstalled everything and reinstalled it about 50 times already. It's simply just broken.



                                    so the fix is.... "just apply a few settings each time you boot your pc, which allows 90% of host names to resolve but wget and apt-get updates and upgrades will fail randomly for no reason"



                                    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=yes
                                    #MulticastDNS=yes
                                    #DNSSEC=no
                                    #Cache=yes
                                    #DNSStubListener=udp


                                    When using Ubuntu 17.10 Desktop, you have to edit the one file that says DO NOT EDIT THIS FILE BLAH BLAH BLAH



                                    well that's the ONLY way it works~!



                                    root@nas:~# cat /etc/resolv.conf
                                    # This file is managed by man:systemd-resolved(8). Do not edit.
                                    #
                                    # 127.0.0.53 is the systemd-resolved stub resolver.
                                    # run "systemd-resolve --status" to see details about the actual nameservers.
                                    nameserver 8.8.8.8


                                    So remove the 127.0.0.53 IP as the name server and enter another one, google for example. It appears my actual DNS IP address doesn't resolve host names either (even though it works on 10 other machines and devices in the house), but google's works fine.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Dec 29 '17 at 8:30









                                    ravery

                                    5,47351132




                                    5,47351132










                                    answered Dec 29 '17 at 6:42







                                    user776499





































                                        draft saved

                                        draft discarded




















































                                        Thanks for contributing an answer to Ask Ubuntu!


                                        • Please be sure to answer the question. Provide details and share your research!

                                        But avoid



                                        • Asking for help, clarification, or responding to other answers.

                                        • Making statements based on opinion; back them up with references or personal experience.


                                        To learn more, see our tips on writing great answers.




                                        draft saved


                                        draft discarded














                                        StackExchange.ready(
                                        function () {
                                        StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f973017%2fwrong-nameserver-set-by-resolvconf-and-networkmanager%23new-answer', 'question_page');
                                        }
                                        );

                                        Post as a guest















                                        Required, but never shown





















































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown

































                                        Required, but never shown














                                        Required, but never shown












                                        Required, but never shown







                                        Required, but never shown







                                        Popular posts from this blog

                                        flock() on closed filehandle LOCK_FILE at /usr/bin/apt-mirror

                                        Mangá

                                        Eduardo VII do Reino Unido