How to change DNS server on command line?












0















Is there any way to change the DNS server that the system use on the command line?



Some say the following would work,



nmcli con mod <connectionName> ipv4.dns "8.8.8.8 8.8.4.4"


but having done that, dig still says it's using local DNS:



;; ANSWER SECTION:
google.com. 150 IN A 172.217.2.174

;; Query time: 14 msec
;; SERVER: 127.0.0.53#53(127.0.0.53)


Is it possible at all?










share|improve this question



























    0















    Is there any way to change the DNS server that the system use on the command line?



    Some say the following would work,



    nmcli con mod <connectionName> ipv4.dns "8.8.8.8 8.8.4.4"


    but having done that, dig still says it's using local DNS:



    ;; ANSWER SECTION:
    google.com. 150 IN A 172.217.2.174

    ;; Query time: 14 msec
    ;; SERVER: 127.0.0.53#53(127.0.0.53)


    Is it possible at all?










    share|improve this question

























      0












      0








      0








      Is there any way to change the DNS server that the system use on the command line?



      Some say the following would work,



      nmcli con mod <connectionName> ipv4.dns "8.8.8.8 8.8.4.4"


      but having done that, dig still says it's using local DNS:



      ;; ANSWER SECTION:
      google.com. 150 IN A 172.217.2.174

      ;; Query time: 14 msec
      ;; SERVER: 127.0.0.53#53(127.0.0.53)


      Is it possible at all?










      share|improve this question














      Is there any way to change the DNS server that the system use on the command line?



      Some say the following would work,



      nmcli con mod <connectionName> ipv4.dns "8.8.8.8 8.8.4.4"


      but having done that, dig still says it's using local DNS:



      ;; ANSWER SECTION:
      google.com. 150 IN A 172.217.2.174

      ;; Query time: 14 msec
      ;; SERVER: 127.0.0.53#53(127.0.0.53)


      Is it possible at all?







      ubuntu dns






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Jan 4 at 5:33









      xptxpt

      3,176115390




      3,176115390






















          3 Answers
          3






          active

          oldest

          votes


















          0














          The bottom line is that you need to modify the appropriate nameserver line(s) in your /etc/resolve.conf file to change the active nameserver. Depending on your specific distro and conf this may or may not be permanent - normally not because of a network manager or setup script overwriting it.



          The easiest way to do this is with a text editor (vi, pick or whatever). Depending in exactly what it contains and what you want to replace it with you can probably write a script or command to do this.



          If you want specific OS instructions you need to advise the distro version and possibly other specifics.






          share|improve this answer































            0















            • Found the answer for nmcli at
              https://askubuntu.com/a/922011/843820

              It's almost perfect, only the last step, the "then you should disable "dnsmasq"" one, I can't follow under my Ubuntu 18.04 now. Once that's over come it's a perfect answer to changing DNS server using commands.


            • Moreover, there are also other options like using resolvconf or even dnsmasq directly, and the solution is at https://unix.stackexchange.com/a/323498







            share|improve this answer

































              0














              The syntax you are using is correct but since you are using NetworkManager nmcli, in order for this to apply you have to bring the connection down and up again. As follows:



              nmcli con down <conname>; nmcli con up <conname>



              I hope this helps.






              share|improve this answer
























              • Thanks. that's covered in my already-posted link askubuntu.com/a/922011/843820, and the answer further explains why bring the connection down and up again doesn't work for my case.

                – xpt
                Jan 5 at 14:49











              • @xpt sorry I missed that. I'm not a regular user of Debian based distros. I've set up a VM box running Ubuntu 18.04 and by default network services were managed by netplan which is new for me. Have you heard of it? if not, click here. I managed to change the DNS servers but the resolv.conf file shows nameserver 127.x.x.x, which apparently is set up because systemd uses a service called systemd-resolved.service that runs a local name server.

                – Manuel Florian
                Jan 5 at 23:19













              Your Answer








              StackExchange.ready(function() {
              var channelOptions = {
              tags: "".split(" "),
              id: "3"
              };
              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%2fsuperuser.com%2fquestions%2f1390378%2fhow-to-change-dns-server-on-command-line%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









              0














              The bottom line is that you need to modify the appropriate nameserver line(s) in your /etc/resolve.conf file to change the active nameserver. Depending on your specific distro and conf this may or may not be permanent - normally not because of a network manager or setup script overwriting it.



              The easiest way to do this is with a text editor (vi, pick or whatever). Depending in exactly what it contains and what you want to replace it with you can probably write a script or command to do this.



              If you want specific OS instructions you need to advise the distro version and possibly other specifics.






              share|improve this answer




























                0














                The bottom line is that you need to modify the appropriate nameserver line(s) in your /etc/resolve.conf file to change the active nameserver. Depending on your specific distro and conf this may or may not be permanent - normally not because of a network manager or setup script overwriting it.



                The easiest way to do this is with a text editor (vi, pick or whatever). Depending in exactly what it contains and what you want to replace it with you can probably write a script or command to do this.



                If you want specific OS instructions you need to advise the distro version and possibly other specifics.






                share|improve this answer


























                  0












                  0








                  0







                  The bottom line is that you need to modify the appropriate nameserver line(s) in your /etc/resolve.conf file to change the active nameserver. Depending on your specific distro and conf this may or may not be permanent - normally not because of a network manager or setup script overwriting it.



                  The easiest way to do this is with a text editor (vi, pick or whatever). Depending in exactly what it contains and what you want to replace it with you can probably write a script or command to do this.



                  If you want specific OS instructions you need to advise the distro version and possibly other specifics.






                  share|improve this answer













                  The bottom line is that you need to modify the appropriate nameserver line(s) in your /etc/resolve.conf file to change the active nameserver. Depending on your specific distro and conf this may or may not be permanent - normally not because of a network manager or setup script overwriting it.



                  The easiest way to do this is with a text editor (vi, pick or whatever). Depending in exactly what it contains and what you want to replace it with you can probably write a script or command to do this.



                  If you want specific OS instructions you need to advise the distro version and possibly other specifics.







                  share|improve this answer












                  share|improve this answer



                  share|improve this answer










                  answered Jan 4 at 6:45









                  davidgodavidgo

                  43.7k75291




                  43.7k75291

























                      0















                      • Found the answer for nmcli at
                        https://askubuntu.com/a/922011/843820

                        It's almost perfect, only the last step, the "then you should disable "dnsmasq"" one, I can't follow under my Ubuntu 18.04 now. Once that's over come it's a perfect answer to changing DNS server using commands.


                      • Moreover, there are also other options like using resolvconf or even dnsmasq directly, and the solution is at https://unix.stackexchange.com/a/323498







                      share|improve this answer






























                        0















                        • Found the answer for nmcli at
                          https://askubuntu.com/a/922011/843820

                          It's almost perfect, only the last step, the "then you should disable "dnsmasq"" one, I can't follow under my Ubuntu 18.04 now. Once that's over come it's a perfect answer to changing DNS server using commands.


                        • Moreover, there are also other options like using resolvconf or even dnsmasq directly, and the solution is at https://unix.stackexchange.com/a/323498







                        share|improve this answer




























                          0












                          0








                          0








                          • Found the answer for nmcli at
                            https://askubuntu.com/a/922011/843820

                            It's almost perfect, only the last step, the "then you should disable "dnsmasq"" one, I can't follow under my Ubuntu 18.04 now. Once that's over come it's a perfect answer to changing DNS server using commands.


                          • Moreover, there are also other options like using resolvconf or even dnsmasq directly, and the solution is at https://unix.stackexchange.com/a/323498







                          share|improve this answer
















                          • Found the answer for nmcli at
                            https://askubuntu.com/a/922011/843820

                            It's almost perfect, only the last step, the "then you should disable "dnsmasq"" one, I can't follow under my Ubuntu 18.04 now. Once that's over come it's a perfect answer to changing DNS server using commands.


                          • Moreover, there are also other options like using resolvconf or even dnsmasq directly, and the solution is at https://unix.stackexchange.com/a/323498








                          share|improve this answer














                          share|improve this answer



                          share|improve this answer








                          edited Jan 5 at 3:31

























                          answered Jan 5 at 1:03









                          xptxpt

                          3,176115390




                          3,176115390























                              0














                              The syntax you are using is correct but since you are using NetworkManager nmcli, in order for this to apply you have to bring the connection down and up again. As follows:



                              nmcli con down <conname>; nmcli con up <conname>



                              I hope this helps.






                              share|improve this answer
























                              • Thanks. that's covered in my already-posted link askubuntu.com/a/922011/843820, and the answer further explains why bring the connection down and up again doesn't work for my case.

                                – xpt
                                Jan 5 at 14:49











                              • @xpt sorry I missed that. I'm not a regular user of Debian based distros. I've set up a VM box running Ubuntu 18.04 and by default network services were managed by netplan which is new for me. Have you heard of it? if not, click here. I managed to change the DNS servers but the resolv.conf file shows nameserver 127.x.x.x, which apparently is set up because systemd uses a service called systemd-resolved.service that runs a local name server.

                                – Manuel Florian
                                Jan 5 at 23:19


















                              0














                              The syntax you are using is correct but since you are using NetworkManager nmcli, in order for this to apply you have to bring the connection down and up again. As follows:



                              nmcli con down <conname>; nmcli con up <conname>



                              I hope this helps.






                              share|improve this answer
























                              • Thanks. that's covered in my already-posted link askubuntu.com/a/922011/843820, and the answer further explains why bring the connection down and up again doesn't work for my case.

                                – xpt
                                Jan 5 at 14:49











                              • @xpt sorry I missed that. I'm not a regular user of Debian based distros. I've set up a VM box running Ubuntu 18.04 and by default network services were managed by netplan which is new for me. Have you heard of it? if not, click here. I managed to change the DNS servers but the resolv.conf file shows nameserver 127.x.x.x, which apparently is set up because systemd uses a service called systemd-resolved.service that runs a local name server.

                                – Manuel Florian
                                Jan 5 at 23:19
















                              0












                              0








                              0







                              The syntax you are using is correct but since you are using NetworkManager nmcli, in order for this to apply you have to bring the connection down and up again. As follows:



                              nmcli con down <conname>; nmcli con up <conname>



                              I hope this helps.






                              share|improve this answer













                              The syntax you are using is correct but since you are using NetworkManager nmcli, in order for this to apply you have to bring the connection down and up again. As follows:



                              nmcli con down <conname>; nmcli con up <conname>



                              I hope this helps.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Jan 5 at 6:05









                              Manuel FlorianManuel Florian

                              1595




                              1595













                              • Thanks. that's covered in my already-posted link askubuntu.com/a/922011/843820, and the answer further explains why bring the connection down and up again doesn't work for my case.

                                – xpt
                                Jan 5 at 14:49











                              • @xpt sorry I missed that. I'm not a regular user of Debian based distros. I've set up a VM box running Ubuntu 18.04 and by default network services were managed by netplan which is new for me. Have you heard of it? if not, click here. I managed to change the DNS servers but the resolv.conf file shows nameserver 127.x.x.x, which apparently is set up because systemd uses a service called systemd-resolved.service that runs a local name server.

                                – Manuel Florian
                                Jan 5 at 23:19





















                              • Thanks. that's covered in my already-posted link askubuntu.com/a/922011/843820, and the answer further explains why bring the connection down and up again doesn't work for my case.

                                – xpt
                                Jan 5 at 14:49











                              • @xpt sorry I missed that. I'm not a regular user of Debian based distros. I've set up a VM box running Ubuntu 18.04 and by default network services were managed by netplan which is new for me. Have you heard of it? if not, click here. I managed to change the DNS servers but the resolv.conf file shows nameserver 127.x.x.x, which apparently is set up because systemd uses a service called systemd-resolved.service that runs a local name server.

                                – Manuel Florian
                                Jan 5 at 23:19



















                              Thanks. that's covered in my already-posted link askubuntu.com/a/922011/843820, and the answer further explains why bring the connection down and up again doesn't work for my case.

                              – xpt
                              Jan 5 at 14:49





                              Thanks. that's covered in my already-posted link askubuntu.com/a/922011/843820, and the answer further explains why bring the connection down and up again doesn't work for my case.

                              – xpt
                              Jan 5 at 14:49













                              @xpt sorry I missed that. I'm not a regular user of Debian based distros. I've set up a VM box running Ubuntu 18.04 and by default network services were managed by netplan which is new for me. Have you heard of it? if not, click here. I managed to change the DNS servers but the resolv.conf file shows nameserver 127.x.x.x, which apparently is set up because systemd uses a service called systemd-resolved.service that runs a local name server.

                              – Manuel Florian
                              Jan 5 at 23:19







                              @xpt sorry I missed that. I'm not a regular user of Debian based distros. I've set up a VM box running Ubuntu 18.04 and by default network services were managed by netplan which is new for me. Have you heard of it? if not, click here. I managed to change the DNS servers but the resolv.conf file shows nameserver 127.x.x.x, which apparently is set up because systemd uses a service called systemd-resolved.service that runs a local name server.

                              – Manuel Florian
                              Jan 5 at 23:19




















                              draft saved

                              draft discarded




















































                              Thanks for contributing an answer to Super User!


                              • 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%2fsuperuser.com%2fquestions%2f1390378%2fhow-to-change-dns-server-on-command-line%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

                              Plaza Victoria

                              Brian Clough

                              Cáceres