Can netplan configured nameservers supersede (not merge with) the DHCP nameservers?





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







4















I would like to use DHCP to assign an IP address to my server, but specify the DNS servers manually. I tried the following simple configuration:



network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
nameservers: [8.8.8.8,8.8.4.4]


After running netplan apply I check the nameservers with systemd-resolve --status and it shows:



DNS Servers: 8.8.8.8
8.8.4.4
192.168.1.1


The last is the DNS server provided by DHCP, which I do not want to be in the list.



Does netplan have a way to accomplish this?










share|improve this question

























  • You may find the answer here helpful unix.stackexchange.com/questions/136117/…

    – nucc1
    May 5 '18 at 12:35











  • I appreciate the attempt to help, but dhclient.conf does not appear to affect netplan configured DHCP at all. In fact, on Ubuntu 17.10 I found that you could delete the dhclient binary and netplan would still configure everything with DHCP.

    – alanwj
    May 7 '18 at 7:18











  • I found the bug (you?) filed on netplan for this: bugs.launchpad.net/netplan/+bug/1759014 I skimmed the netplan code and it doesn't support any way to specify DHCP options. It is hardcoded to write two options "UseMTU" and "RouteMetric". The only way I can think of for "hacking" what you want is to manually (or using a script) edit the files in /run/systemd/network/10-netplan-* which is where networkd reads definitions from. YOu can append the dhcp options you want there . doesn't look too complex to support this, so maybe we will see a patch in our lifetimes.

    – nucc1
    May 7 '18 at 11:36













  • of course, as you know, the files will be overwritten every time you call netplan apply... also, my comments are based on Ubuntu 18.04 and the current Master of netplan.

    – nucc1
    May 7 '18 at 11:45




















4















I would like to use DHCP to assign an IP address to my server, but specify the DNS servers manually. I tried the following simple configuration:



network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
nameservers: [8.8.8.8,8.8.4.4]


After running netplan apply I check the nameservers with systemd-resolve --status and it shows:



DNS Servers: 8.8.8.8
8.8.4.4
192.168.1.1


The last is the DNS server provided by DHCP, which I do not want to be in the list.



Does netplan have a way to accomplish this?










share|improve this question

























  • You may find the answer here helpful unix.stackexchange.com/questions/136117/…

    – nucc1
    May 5 '18 at 12:35











  • I appreciate the attempt to help, but dhclient.conf does not appear to affect netplan configured DHCP at all. In fact, on Ubuntu 17.10 I found that you could delete the dhclient binary and netplan would still configure everything with DHCP.

    – alanwj
    May 7 '18 at 7:18











  • I found the bug (you?) filed on netplan for this: bugs.launchpad.net/netplan/+bug/1759014 I skimmed the netplan code and it doesn't support any way to specify DHCP options. It is hardcoded to write two options "UseMTU" and "RouteMetric". The only way I can think of for "hacking" what you want is to manually (or using a script) edit the files in /run/systemd/network/10-netplan-* which is where networkd reads definitions from. YOu can append the dhcp options you want there . doesn't look too complex to support this, so maybe we will see a patch in our lifetimes.

    – nucc1
    May 7 '18 at 11:36













  • of course, as you know, the files will be overwritten every time you call netplan apply... also, my comments are based on Ubuntu 18.04 and the current Master of netplan.

    – nucc1
    May 7 '18 at 11:45
















4












4








4








I would like to use DHCP to assign an IP address to my server, but specify the DNS servers manually. I tried the following simple configuration:



network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
nameservers: [8.8.8.8,8.8.4.4]


After running netplan apply I check the nameservers with systemd-resolve --status and it shows:



DNS Servers: 8.8.8.8
8.8.4.4
192.168.1.1


The last is the DNS server provided by DHCP, which I do not want to be in the list.



Does netplan have a way to accomplish this?










share|improve this question
















I would like to use DHCP to assign an IP address to my server, but specify the DNS servers manually. I tried the following simple configuration:



network:
version: 2
renderer: networkd
ethernets:
enp0s3:
dhcp4: yes
nameservers: [8.8.8.8,8.8.4.4]


After running netplan apply I check the nameservers with systemd-resolve --status and it shows:



DNS Servers: 8.8.8.8
8.8.4.4
192.168.1.1


The last is the DNS server provided by DHCP, which I do not want to be in the list.



Does netplan have a way to accomplish this?







networking 17.10 dns dhcp netplan






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Apr 2 at 3:10









timbo

179111




179111










asked Jan 30 '18 at 7:01









alanwjalanwj

14115




14115













  • You may find the answer here helpful unix.stackexchange.com/questions/136117/…

    – nucc1
    May 5 '18 at 12:35











  • I appreciate the attempt to help, but dhclient.conf does not appear to affect netplan configured DHCP at all. In fact, on Ubuntu 17.10 I found that you could delete the dhclient binary and netplan would still configure everything with DHCP.

    – alanwj
    May 7 '18 at 7:18











  • I found the bug (you?) filed on netplan for this: bugs.launchpad.net/netplan/+bug/1759014 I skimmed the netplan code and it doesn't support any way to specify DHCP options. It is hardcoded to write two options "UseMTU" and "RouteMetric". The only way I can think of for "hacking" what you want is to manually (or using a script) edit the files in /run/systemd/network/10-netplan-* which is where networkd reads definitions from. YOu can append the dhcp options you want there . doesn't look too complex to support this, so maybe we will see a patch in our lifetimes.

    – nucc1
    May 7 '18 at 11:36













  • of course, as you know, the files will be overwritten every time you call netplan apply... also, my comments are based on Ubuntu 18.04 and the current Master of netplan.

    – nucc1
    May 7 '18 at 11:45





















  • You may find the answer here helpful unix.stackexchange.com/questions/136117/…

    – nucc1
    May 5 '18 at 12:35











  • I appreciate the attempt to help, but dhclient.conf does not appear to affect netplan configured DHCP at all. In fact, on Ubuntu 17.10 I found that you could delete the dhclient binary and netplan would still configure everything with DHCP.

    – alanwj
    May 7 '18 at 7:18











  • I found the bug (you?) filed on netplan for this: bugs.launchpad.net/netplan/+bug/1759014 I skimmed the netplan code and it doesn't support any way to specify DHCP options. It is hardcoded to write two options "UseMTU" and "RouteMetric". The only way I can think of for "hacking" what you want is to manually (or using a script) edit the files in /run/systemd/network/10-netplan-* which is where networkd reads definitions from. YOu can append the dhcp options you want there . doesn't look too complex to support this, so maybe we will see a patch in our lifetimes.

    – nucc1
    May 7 '18 at 11:36













  • of course, as you know, the files will be overwritten every time you call netplan apply... also, my comments are based on Ubuntu 18.04 and the current Master of netplan.

    – nucc1
    May 7 '18 at 11:45



















You may find the answer here helpful unix.stackexchange.com/questions/136117/…

– nucc1
May 5 '18 at 12:35





You may find the answer here helpful unix.stackexchange.com/questions/136117/…

– nucc1
May 5 '18 at 12:35













I appreciate the attempt to help, but dhclient.conf does not appear to affect netplan configured DHCP at all. In fact, on Ubuntu 17.10 I found that you could delete the dhclient binary and netplan would still configure everything with DHCP.

– alanwj
May 7 '18 at 7:18





I appreciate the attempt to help, but dhclient.conf does not appear to affect netplan configured DHCP at all. In fact, on Ubuntu 17.10 I found that you could delete the dhclient binary and netplan would still configure everything with DHCP.

– alanwj
May 7 '18 at 7:18













I found the bug (you?) filed on netplan for this: bugs.launchpad.net/netplan/+bug/1759014 I skimmed the netplan code and it doesn't support any way to specify DHCP options. It is hardcoded to write two options "UseMTU" and "RouteMetric". The only way I can think of for "hacking" what you want is to manually (or using a script) edit the files in /run/systemd/network/10-netplan-* which is where networkd reads definitions from. YOu can append the dhcp options you want there . doesn't look too complex to support this, so maybe we will see a patch in our lifetimes.

– nucc1
May 7 '18 at 11:36







I found the bug (you?) filed on netplan for this: bugs.launchpad.net/netplan/+bug/1759014 I skimmed the netplan code and it doesn't support any way to specify DHCP options. It is hardcoded to write two options "UseMTU" and "RouteMetric". The only way I can think of for "hacking" what you want is to manually (or using a script) edit the files in /run/systemd/network/10-netplan-* which is where networkd reads definitions from. YOu can append the dhcp options you want there . doesn't look too complex to support this, so maybe we will see a patch in our lifetimes.

– nucc1
May 7 '18 at 11:36















of course, as you know, the files will be overwritten every time you call netplan apply... also, my comments are based on Ubuntu 18.04 and the current Master of netplan.

– nucc1
May 7 '18 at 11:45







of course, as you know, the files will be overwritten every time you call netplan apply... also, my comments are based on Ubuntu 18.04 and the current Master of netplan.

– nucc1
May 7 '18 at 11:45












3 Answers
3






active

oldest

votes


















2














This is a really common setup that's totally borked in Ubuntu 18.04,
Netplan needs to support the NetworkManager options when using DHCP:



nmcli connection modify ${ID} ipv4.ignore-auto-dns yes
nmcli connection modify ${ID} ipv4.dns 'xx.xx.xx.10 xx.xx.xx.20'
nmcli connection modify ${ID} ipv4.dns-search 'abc01.domain.com. abc02.domain.com.'





share|improve this answer

































    2














    This has been fixed in the netplan repository on github, and will presumably make its way into Ubuntu at some point.



    Two new options have been added, dhcp4-overrides and dhcp6-overrides. To ignore DNS servers from DHCP you would do something like:



    dhcp4: yes
    dhcp4-overrides:
    use-dns: no





    share|improve this answer



















    • 1





      I agree this is the best fix. However, if you don't have the latest netplan (for example, you're on 18.04 like me), you can instead append "UseDNS=false" to /run/systemd/network/10-netplan-*.network, then execute systemctl restart systemd-networkd. Note that a future netplan apply will clobber this. (Info from bugs.launchpad.net/netplan/+bug/1759014/comments/5)

      – Chris
      Jan 22 at 15:19



















    0














    There is unfortunately no changelog in the netplan github repo to ascertain when the newer features came in. However there was a big jump in release versions in
    https://github.com/CanonicalLtd/netplan/releases from 0.40 to 0.90 in November 2018



    On Ubuntu 18.10, netplan is presently at version 0.40.2.2



    With that netplan version, trying a wireless config to do DHCP but with the Cloudflare anonymous DNS servers:



    network:
    version: 2
    renderer: NetworkManager
    ethernets:
    wlp4s0:
    dhcp4: yes
    dhcp4-overrides:
    use-dns: no
    nameservers:
    addresses: [1.1.1.1,1.0.0.1]


    produces an Unknown key dhcp4-overrides error:



    enter image description here



    There are no backports to cosmic according to ubuntu.packages.org



    On Ubuntu 19.04 beta, netplan version 0.96 is installed and the dhcp4-overrides can be used:



    enter image description here






    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%2f1001241%2fcan-netplan-configured-nameservers-supersede-not-merge-with-the-dhcp-nameserve%23new-answer', 'question_page');
      }
      );

      Post as a guest















      Required, but never shown

























      3 Answers
      3






      active

      oldest

      votes








      3 Answers
      3






      active

      oldest

      votes









      active

      oldest

      votes






      active

      oldest

      votes









      2














      This is a really common setup that's totally borked in Ubuntu 18.04,
      Netplan needs to support the NetworkManager options when using DHCP:



      nmcli connection modify ${ID} ipv4.ignore-auto-dns yes
      nmcli connection modify ${ID} ipv4.dns 'xx.xx.xx.10 xx.xx.xx.20'
      nmcli connection modify ${ID} ipv4.dns-search 'abc01.domain.com. abc02.domain.com.'





      share|improve this answer






























        2














        This is a really common setup that's totally borked in Ubuntu 18.04,
        Netplan needs to support the NetworkManager options when using DHCP:



        nmcli connection modify ${ID} ipv4.ignore-auto-dns yes
        nmcli connection modify ${ID} ipv4.dns 'xx.xx.xx.10 xx.xx.xx.20'
        nmcli connection modify ${ID} ipv4.dns-search 'abc01.domain.com. abc02.domain.com.'





        share|improve this answer




























          2












          2








          2







          This is a really common setup that's totally borked in Ubuntu 18.04,
          Netplan needs to support the NetworkManager options when using DHCP:



          nmcli connection modify ${ID} ipv4.ignore-auto-dns yes
          nmcli connection modify ${ID} ipv4.dns 'xx.xx.xx.10 xx.xx.xx.20'
          nmcli connection modify ${ID} ipv4.dns-search 'abc01.domain.com. abc02.domain.com.'





          share|improve this answer















          This is a really common setup that's totally borked in Ubuntu 18.04,
          Netplan needs to support the NetworkManager options when using DHCP:



          nmcli connection modify ${ID} ipv4.ignore-auto-dns yes
          nmcli connection modify ${ID} ipv4.dns 'xx.xx.xx.10 xx.xx.xx.20'
          nmcli connection modify ${ID} ipv4.dns-search 'abc01.domain.com. abc02.domain.com.'






          share|improve this answer














          share|improve this answer



          share|improve this answer








          edited May 7 '18 at 19:20









          Zoe

          11524




          11524










          answered May 7 '18 at 19:06









          WildstalkerWildstalker

          314




          314

























              2














              This has been fixed in the netplan repository on github, and will presumably make its way into Ubuntu at some point.



              Two new options have been added, dhcp4-overrides and dhcp6-overrides. To ignore DNS servers from DHCP you would do something like:



              dhcp4: yes
              dhcp4-overrides:
              use-dns: no





              share|improve this answer



















              • 1





                I agree this is the best fix. However, if you don't have the latest netplan (for example, you're on 18.04 like me), you can instead append "UseDNS=false" to /run/systemd/network/10-netplan-*.network, then execute systemctl restart systemd-networkd. Note that a future netplan apply will clobber this. (Info from bugs.launchpad.net/netplan/+bug/1759014/comments/5)

                – Chris
                Jan 22 at 15:19
















              2














              This has been fixed in the netplan repository on github, and will presumably make its way into Ubuntu at some point.



              Two new options have been added, dhcp4-overrides and dhcp6-overrides. To ignore DNS servers from DHCP you would do something like:



              dhcp4: yes
              dhcp4-overrides:
              use-dns: no





              share|improve this answer



















              • 1





                I agree this is the best fix. However, if you don't have the latest netplan (for example, you're on 18.04 like me), you can instead append "UseDNS=false" to /run/systemd/network/10-netplan-*.network, then execute systemctl restart systemd-networkd. Note that a future netplan apply will clobber this. (Info from bugs.launchpad.net/netplan/+bug/1759014/comments/5)

                – Chris
                Jan 22 at 15:19














              2












              2








              2







              This has been fixed in the netplan repository on github, and will presumably make its way into Ubuntu at some point.



              Two new options have been added, dhcp4-overrides and dhcp6-overrides. To ignore DNS servers from DHCP you would do something like:



              dhcp4: yes
              dhcp4-overrides:
              use-dns: no





              share|improve this answer













              This has been fixed in the netplan repository on github, and will presumably make its way into Ubuntu at some point.



              Two new options have been added, dhcp4-overrides and dhcp6-overrides. To ignore DNS servers from DHCP you would do something like:



              dhcp4: yes
              dhcp4-overrides:
              use-dns: no






              share|improve this answer












              share|improve this answer



              share|improve this answer










              answered Oct 18 '18 at 2:48









              alanwjalanwj

              14115




              14115








              • 1





                I agree this is the best fix. However, if you don't have the latest netplan (for example, you're on 18.04 like me), you can instead append "UseDNS=false" to /run/systemd/network/10-netplan-*.network, then execute systemctl restart systemd-networkd. Note that a future netplan apply will clobber this. (Info from bugs.launchpad.net/netplan/+bug/1759014/comments/5)

                – Chris
                Jan 22 at 15:19














              • 1





                I agree this is the best fix. However, if you don't have the latest netplan (for example, you're on 18.04 like me), you can instead append "UseDNS=false" to /run/systemd/network/10-netplan-*.network, then execute systemctl restart systemd-networkd. Note that a future netplan apply will clobber this. (Info from bugs.launchpad.net/netplan/+bug/1759014/comments/5)

                – Chris
                Jan 22 at 15:19








              1




              1





              I agree this is the best fix. However, if you don't have the latest netplan (for example, you're on 18.04 like me), you can instead append "UseDNS=false" to /run/systemd/network/10-netplan-*.network, then execute systemctl restart systemd-networkd. Note that a future netplan apply will clobber this. (Info from bugs.launchpad.net/netplan/+bug/1759014/comments/5)

              – Chris
              Jan 22 at 15:19





              I agree this is the best fix. However, if you don't have the latest netplan (for example, you're on 18.04 like me), you can instead append "UseDNS=false" to /run/systemd/network/10-netplan-*.network, then execute systemctl restart systemd-networkd. Note that a future netplan apply will clobber this. (Info from bugs.launchpad.net/netplan/+bug/1759014/comments/5)

              – Chris
              Jan 22 at 15:19











              0














              There is unfortunately no changelog in the netplan github repo to ascertain when the newer features came in. However there was a big jump in release versions in
              https://github.com/CanonicalLtd/netplan/releases from 0.40 to 0.90 in November 2018



              On Ubuntu 18.10, netplan is presently at version 0.40.2.2



              With that netplan version, trying a wireless config to do DHCP but with the Cloudflare anonymous DNS servers:



              network:
              version: 2
              renderer: NetworkManager
              ethernets:
              wlp4s0:
              dhcp4: yes
              dhcp4-overrides:
              use-dns: no
              nameservers:
              addresses: [1.1.1.1,1.0.0.1]


              produces an Unknown key dhcp4-overrides error:



              enter image description here



              There are no backports to cosmic according to ubuntu.packages.org



              On Ubuntu 19.04 beta, netplan version 0.96 is installed and the dhcp4-overrides can be used:



              enter image description here






              share|improve this answer






























                0














                There is unfortunately no changelog in the netplan github repo to ascertain when the newer features came in. However there was a big jump in release versions in
                https://github.com/CanonicalLtd/netplan/releases from 0.40 to 0.90 in November 2018



                On Ubuntu 18.10, netplan is presently at version 0.40.2.2



                With that netplan version, trying a wireless config to do DHCP but with the Cloudflare anonymous DNS servers:



                network:
                version: 2
                renderer: NetworkManager
                ethernets:
                wlp4s0:
                dhcp4: yes
                dhcp4-overrides:
                use-dns: no
                nameservers:
                addresses: [1.1.1.1,1.0.0.1]


                produces an Unknown key dhcp4-overrides error:



                enter image description here



                There are no backports to cosmic according to ubuntu.packages.org



                On Ubuntu 19.04 beta, netplan version 0.96 is installed and the dhcp4-overrides can be used:



                enter image description here






                share|improve this answer




























                  0












                  0








                  0







                  There is unfortunately no changelog in the netplan github repo to ascertain when the newer features came in. However there was a big jump in release versions in
                  https://github.com/CanonicalLtd/netplan/releases from 0.40 to 0.90 in November 2018



                  On Ubuntu 18.10, netplan is presently at version 0.40.2.2



                  With that netplan version, trying a wireless config to do DHCP but with the Cloudflare anonymous DNS servers:



                  network:
                  version: 2
                  renderer: NetworkManager
                  ethernets:
                  wlp4s0:
                  dhcp4: yes
                  dhcp4-overrides:
                  use-dns: no
                  nameservers:
                  addresses: [1.1.1.1,1.0.0.1]


                  produces an Unknown key dhcp4-overrides error:



                  enter image description here



                  There are no backports to cosmic according to ubuntu.packages.org



                  On Ubuntu 19.04 beta, netplan version 0.96 is installed and the dhcp4-overrides can be used:



                  enter image description here






                  share|improve this answer















                  There is unfortunately no changelog in the netplan github repo to ascertain when the newer features came in. However there was a big jump in release versions in
                  https://github.com/CanonicalLtd/netplan/releases from 0.40 to 0.90 in November 2018



                  On Ubuntu 18.10, netplan is presently at version 0.40.2.2



                  With that netplan version, trying a wireless config to do DHCP but with the Cloudflare anonymous DNS servers:



                  network:
                  version: 2
                  renderer: NetworkManager
                  ethernets:
                  wlp4s0:
                  dhcp4: yes
                  dhcp4-overrides:
                  use-dns: no
                  nameservers:
                  addresses: [1.1.1.1,1.0.0.1]


                  produces an Unknown key dhcp4-overrides error:



                  enter image description here



                  There are no backports to cosmic according to ubuntu.packages.org



                  On Ubuntu 19.04 beta, netplan version 0.96 is installed and the dhcp4-overrides can be used:



                  enter image description here







                  share|improve this answer














                  share|improve this answer



                  share|improve this answer








                  edited Apr 2 at 3:09

























                  answered Apr 1 at 23:11









                  timbotimbo

                  179111




                  179111






























                      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%2f1001241%2fcan-netplan-configured-nameservers-supersede-not-merge-with-the-dhcp-nameserve%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

                      數位音樂下載

                      When can things happen in Etherscan, such as the picture below?

                      格利澤436b