How can I forward queries from a DNS to another depending on the IP address?












1














I set two DNS servers using bind9 which recieve queries from other PCs on a LAN. Both pc's have their own domain and so far I managed to make the main server redirect queries to the backup one if they request for a domain that is not in it. Now, the last thing I have to do is to respond to queries from different servers depending on the client's IP address.



I have two lists containing ip addresses that are on my LAN: Linuxes and VPCS



I need to make the main DNS server respond to queries from Linuxes, and the backup server to respond to queries coming from VPCS. Whenever I test it I'm querying a domain that is in the main DNS server, regardless of the list the PC is in. So, I pretty much have to redirect the query to another domain if the client IP address is in the VPCS list. I've been using views and I was successfull in filtering the queries but I still can't redirect them to the other server. I also tried to create another zone but it didn't work.



Main DNS server's ip address is 192.168.1.14 .
Backup DNS server's ip address is 192.168.2.3 .
I'm simulating the entire LAN on gns3 using 2 cisco routers, I've checked them and the settings are ok, so I doubt they're the culprit.



This is my named.conf.local



//
// Do any local configuration here
//

// Consider adding the 1918 zones here, if they are not used in your
// organization
//include "/etc/bind/zones.rfc1918";
include "/etc/bind/named.conf.options";

view "vpcs"{
match-clients{vpcs;};
forwarders {
192.168.1.14;
192.168.2.3;
};
# forward only;
# recursion yes;
zone"zonaP.gg" in {
type master;
file "/etc/bind/for.zonaP.gg";
masterfile-format text;
};

zone "168.192.in-addr.arpa" in {
type master;
file "/etc/bind/rev.zonaP.gg";
masterfile-format text;

};

};

view "linuxes"{
match-clients{any;};
zone "zonaP.gg" in {
type master;
file "/etc/bind/for.zonaP.gg";
masterfile-format text;
};

zone "168.192.in-addr.arpa" in {
type master;
file "/etc/bind/rev.zonaP.gg";
masterfile-format text;
};
};


And this is my named.conf.options



acl linuxes {
192.168.1.11;
192.168.1.3;
192.168.1.14;
192.168.2.4;
192.168.2.3;
192.168.1.19;
192.168.1.20;
};

acl vpcs {
192.168.1.10;
192.168.1.11;
192.168.1.12;
192.168.1.2;
192.168.1.4;
192.168.1.13;
192.168.1.15;
192.168.2.2;
192.168.3.2;
};

options {
directory "/var/cache/bind";
recursion yes;
allow-query {any;};
allow-query-cache {any;};
forwarders{192.168.2.3;};
dnssec-validation auto;
auth-nxdomain no;
listen-on-v6 { any; };
};









share|improve this question





























    1














    I set two DNS servers using bind9 which recieve queries from other PCs on a LAN. Both pc's have their own domain and so far I managed to make the main server redirect queries to the backup one if they request for a domain that is not in it. Now, the last thing I have to do is to respond to queries from different servers depending on the client's IP address.



    I have two lists containing ip addresses that are on my LAN: Linuxes and VPCS



    I need to make the main DNS server respond to queries from Linuxes, and the backup server to respond to queries coming from VPCS. Whenever I test it I'm querying a domain that is in the main DNS server, regardless of the list the PC is in. So, I pretty much have to redirect the query to another domain if the client IP address is in the VPCS list. I've been using views and I was successfull in filtering the queries but I still can't redirect them to the other server. I also tried to create another zone but it didn't work.



    Main DNS server's ip address is 192.168.1.14 .
    Backup DNS server's ip address is 192.168.2.3 .
    I'm simulating the entire LAN on gns3 using 2 cisco routers, I've checked them and the settings are ok, so I doubt they're the culprit.



    This is my named.conf.local



    //
    // Do any local configuration here
    //

    // Consider adding the 1918 zones here, if they are not used in your
    // organization
    //include "/etc/bind/zones.rfc1918";
    include "/etc/bind/named.conf.options";

    view "vpcs"{
    match-clients{vpcs;};
    forwarders {
    192.168.1.14;
    192.168.2.3;
    };
    # forward only;
    # recursion yes;
    zone"zonaP.gg" in {
    type master;
    file "/etc/bind/for.zonaP.gg";
    masterfile-format text;
    };

    zone "168.192.in-addr.arpa" in {
    type master;
    file "/etc/bind/rev.zonaP.gg";
    masterfile-format text;

    };

    };

    view "linuxes"{
    match-clients{any;};
    zone "zonaP.gg" in {
    type master;
    file "/etc/bind/for.zonaP.gg";
    masterfile-format text;
    };

    zone "168.192.in-addr.arpa" in {
    type master;
    file "/etc/bind/rev.zonaP.gg";
    masterfile-format text;
    };
    };


    And this is my named.conf.options



    acl linuxes {
    192.168.1.11;
    192.168.1.3;
    192.168.1.14;
    192.168.2.4;
    192.168.2.3;
    192.168.1.19;
    192.168.1.20;
    };

    acl vpcs {
    192.168.1.10;
    192.168.1.11;
    192.168.1.12;
    192.168.1.2;
    192.168.1.4;
    192.168.1.13;
    192.168.1.15;
    192.168.2.2;
    192.168.3.2;
    };

    options {
    directory "/var/cache/bind";
    recursion yes;
    allow-query {any;};
    allow-query-cache {any;};
    forwarders{192.168.2.3;};
    dnssec-validation auto;
    auth-nxdomain no;
    listen-on-v6 { any; };
    };









    share|improve this question



























      1












      1








      1







      I set two DNS servers using bind9 which recieve queries from other PCs on a LAN. Both pc's have their own domain and so far I managed to make the main server redirect queries to the backup one if they request for a domain that is not in it. Now, the last thing I have to do is to respond to queries from different servers depending on the client's IP address.



      I have two lists containing ip addresses that are on my LAN: Linuxes and VPCS



      I need to make the main DNS server respond to queries from Linuxes, and the backup server to respond to queries coming from VPCS. Whenever I test it I'm querying a domain that is in the main DNS server, regardless of the list the PC is in. So, I pretty much have to redirect the query to another domain if the client IP address is in the VPCS list. I've been using views and I was successfull in filtering the queries but I still can't redirect them to the other server. I also tried to create another zone but it didn't work.



      Main DNS server's ip address is 192.168.1.14 .
      Backup DNS server's ip address is 192.168.2.3 .
      I'm simulating the entire LAN on gns3 using 2 cisco routers, I've checked them and the settings are ok, so I doubt they're the culprit.



      This is my named.conf.local



      //
      // Do any local configuration here
      //

      // Consider adding the 1918 zones here, if they are not used in your
      // organization
      //include "/etc/bind/zones.rfc1918";
      include "/etc/bind/named.conf.options";

      view "vpcs"{
      match-clients{vpcs;};
      forwarders {
      192.168.1.14;
      192.168.2.3;
      };
      # forward only;
      # recursion yes;
      zone"zonaP.gg" in {
      type master;
      file "/etc/bind/for.zonaP.gg";
      masterfile-format text;
      };

      zone "168.192.in-addr.arpa" in {
      type master;
      file "/etc/bind/rev.zonaP.gg";
      masterfile-format text;

      };

      };

      view "linuxes"{
      match-clients{any;};
      zone "zonaP.gg" in {
      type master;
      file "/etc/bind/for.zonaP.gg";
      masterfile-format text;
      };

      zone "168.192.in-addr.arpa" in {
      type master;
      file "/etc/bind/rev.zonaP.gg";
      masterfile-format text;
      };
      };


      And this is my named.conf.options



      acl linuxes {
      192.168.1.11;
      192.168.1.3;
      192.168.1.14;
      192.168.2.4;
      192.168.2.3;
      192.168.1.19;
      192.168.1.20;
      };

      acl vpcs {
      192.168.1.10;
      192.168.1.11;
      192.168.1.12;
      192.168.1.2;
      192.168.1.4;
      192.168.1.13;
      192.168.1.15;
      192.168.2.2;
      192.168.3.2;
      };

      options {
      directory "/var/cache/bind";
      recursion yes;
      allow-query {any;};
      allow-query-cache {any;};
      forwarders{192.168.2.3;};
      dnssec-validation auto;
      auth-nxdomain no;
      listen-on-v6 { any; };
      };









      share|improve this question















      I set two DNS servers using bind9 which recieve queries from other PCs on a LAN. Both pc's have their own domain and so far I managed to make the main server redirect queries to the backup one if they request for a domain that is not in it. Now, the last thing I have to do is to respond to queries from different servers depending on the client's IP address.



      I have two lists containing ip addresses that are on my LAN: Linuxes and VPCS



      I need to make the main DNS server respond to queries from Linuxes, and the backup server to respond to queries coming from VPCS. Whenever I test it I'm querying a domain that is in the main DNS server, regardless of the list the PC is in. So, I pretty much have to redirect the query to another domain if the client IP address is in the VPCS list. I've been using views and I was successfull in filtering the queries but I still can't redirect them to the other server. I also tried to create another zone but it didn't work.



      Main DNS server's ip address is 192.168.1.14 .
      Backup DNS server's ip address is 192.168.2.3 .
      I'm simulating the entire LAN on gns3 using 2 cisco routers, I've checked them and the settings are ok, so I doubt they're the culprit.



      This is my named.conf.local



      //
      // Do any local configuration here
      //

      // Consider adding the 1918 zones here, if they are not used in your
      // organization
      //include "/etc/bind/zones.rfc1918";
      include "/etc/bind/named.conf.options";

      view "vpcs"{
      match-clients{vpcs;};
      forwarders {
      192.168.1.14;
      192.168.2.3;
      };
      # forward only;
      # recursion yes;
      zone"zonaP.gg" in {
      type master;
      file "/etc/bind/for.zonaP.gg";
      masterfile-format text;
      };

      zone "168.192.in-addr.arpa" in {
      type master;
      file "/etc/bind/rev.zonaP.gg";
      masterfile-format text;

      };

      };

      view "linuxes"{
      match-clients{any;};
      zone "zonaP.gg" in {
      type master;
      file "/etc/bind/for.zonaP.gg";
      masterfile-format text;
      };

      zone "168.192.in-addr.arpa" in {
      type master;
      file "/etc/bind/rev.zonaP.gg";
      masterfile-format text;
      };
      };


      And this is my named.conf.options



      acl linuxes {
      192.168.1.11;
      192.168.1.3;
      192.168.1.14;
      192.168.2.4;
      192.168.2.3;
      192.168.1.19;
      192.168.1.20;
      };

      acl vpcs {
      192.168.1.10;
      192.168.1.11;
      192.168.1.12;
      192.168.1.2;
      192.168.1.4;
      192.168.1.13;
      192.168.1.15;
      192.168.2.2;
      192.168.3.2;
      };

      options {
      directory "/var/cache/bind";
      recursion yes;
      allow-query {any;};
      allow-query-cache {any;};
      forwarders{192.168.2.3;};
      dnssec-validation auto;
      auth-nxdomain no;
      listen-on-v6 { any; };
      };






      linux dns bind






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 10 '18 at 8:46

























      asked Dec 10 '18 at 8:33









      George Gibbs

      62




      62



























          active

          oldest

          votes











          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%2f1382257%2fhow-can-i-forward-queries-from-a-dns-to-another-depending-on-the-ip-address%23new-answer', 'question_page');
          }
          );

          Post as a guest















          Required, but never shown






























          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















          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.





          Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


          Please pay close attention to the following guidance:


          • 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%2f1382257%2fhow-can-i-forward-queries-from-a-dns-to-another-depending-on-the-ip-address%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

          Puebla de Zaragoza

          Musa