LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Networking (https://www.linuxquestions.org/questions/linux-networking-3/)
-   -   DNS question (https://www.linuxquestions.org/questions/linux-networking-3/dns-question-4175445015/)

chinese_ys 01-10-2013 10:48 AM

DNS question
 
Hey,

I have a temp DNS server (172.16.0.100) on internal network running openSUSE. There is a special host "host1.test.com" on network that I need internal user to have its private IP when resolving. I created a zone "test.com" in named.conf as redirect and statically added host1.test.com into /etc/hosts file.

named.conf:
zone "test.com" in {
type forward;
forwarders { 127.0.0.1; };
};


I also have 8.8.8.8 configured as my upstream forwarder. My issue is Client PC with 172.16.0.100 as DNS server is not able to resolve host1.test.com. I got timeout message.

So how should I configure the DNS server to be smart enough to forward request to itself to check /etc/hosts and/or upstream forward when client asks for host on test.com domain?

acid_kewpie 01-11-2013 03:18 AM

forwarders { 127.0.0.1; };

?? you're just telling it to forward to itself, that clearly makes no sense, and would just be an infinite loop.

it's really unclear what you're actually asking for. Where does /etc/hosts fit into this? If it's just one client, why bother with DNS at all, just put the entry on the single client surely?

chinese_ys 01-11-2013 06:57 AM

Quote:

Originally Posted by acid_kewpie (Post 4867606)
forwarders { 127.0.0.1; };

?? you're just telling it to forward to itself, that clearly makes no sense, and would just be an infinite loop.

it's really unclear what you're actually asking for. Where does /etc/hosts fit into this? If it's just one client, why bother with DNS at all, just put the entry on the single client surely?

I was expecting forward request to itself in order to use /etc/hosts.

Let me try to explain again:
I have multiple clients(WIFI Guests) on this LAN. When they connect to network, I need to have host1.test.com to be resolved as 172.16.0.254 and host2.test.com as 1.2.3.4; When they are on Internet, I need host1.test.com to be resolved as 1.2.3.3 and host2.test.com as 1.2.3.4 (This part has done via godaddy already). Please keep in mind, there are more than host1 and host2 need to be resolvable.

Any suggestion?

acid_kewpie 01-11-2013 07:12 AM

Hmm, well firstly no, the 127.0.0.1 ideas are nonsense. a BIND instance will never revert to local files, It's a proper service, not a simple utility like dnsmasq. You'd define a proper BIND zone for it, and put the appropriate A record in the zone file.

chinese_ys 01-11-2013 07:30 AM

Quote:

Originally Posted by acid_kewpie (Post 4867699)
Hmm, well firstly no, the 127.0.0.1 ideas are nonsense. a BIND instance will never revert to local files, It's a proper service, not a simple utility like dnsmasq. You'd define a proper BIND zone for it, and put the appropriate A record in the zone file.

I did have the zone for test.com configured the first attempt but did not work as I expected.
So if I have 50 hosts needs to be resolvable on Internet including this host1.test.com, i would need to manaully add all 50 records into the ZONE configuration?

acid_kewpie 01-11-2013 07:32 AM

If you're forwqarding all other unknown addresses, you'd only need the local entries on the local server, asssuming that this local server plays no part at all in the resolution from the interwebs.

chinese_ys 01-11-2013 08:32 AM

Quote:

Originally Posted by acid_kewpie (Post 4867710)
If you're forwqarding all other unknown addresses, you'd only need the local entries on the local server, asssuming that this local server plays no part at all in the resolution from the interwebs.

Sure that is making sense on paper but can you be more specific?

Here was the one I had initially and it did not work as I expected:
named.conf:
zone "test.com" in {
type master;
file "/var/lib/named/master/test.com.hosts";
};


test.com.hosts:
$TTL 2D
@ IN SOA DNS01.test.com. root.DNS01.test.ca. (
2011111800 ; serial
3H ; refresh
1H ; retry
1W ; expiry
1D ) ; minimum

IN NS DNS01.test.com.
vpn IN A 172.16.0.254


My DNS server is the DNS01.test.com.

acid_kewpie 01-11-2013 08:52 AM

OK, looking it up a little more, a slight tweak to what I suggested.

So you have your forwarders set up, so you're resolving all sites to public addresses via your local DNS server. then you add a ZONE PER HOSTNAME, so a zone for test.example.com and othertest.example.com, not for example.com itself:

Code:

    zone "test.example.com" {
            type master;
            file "/etc/bind/zones/test.example.com";
    };

with a zone file like:
Code:

$TTL    604800
@      IN      SOA    test.example.com. (
                              1        ; Serial
                        604800        ; Refresh
                          86400        ; Retry
                        2419200        ; Expire
                        604800 )      ; Negative Cache TTL
;
@                      IN      NS      test.example.com.
test.webdomain.com.    IN      A      10.0.1.20


chinese_ys 01-11-2013 10:13 AM

Quote:

Originally Posted by acid_kewpie (Post 4867766)
OK, looking it up a little more, a slight tweak to what I suggested.
...
then you add a ZONE PER HOSTNAME, so a zone for test.example.com and othertest.example.com, not for example.com itself:
...

That is an awesome idea. Fixed my issue :)


All times are GMT -5. The time now is 03:17 PM.