# caching nameserver

## bassvandijk

I'm trying to setup a caching nameserver for my LAN but I can't get it to work.

/etc/bind/named.conf:

```
options {

        directory "/var/bind/";

        listen-on { 10.0.0.1 };

        allow-transfer { none };

        notify no;

        forwarders { 213.51.129.168; 213.51.144.168 };

        forward only;

        pid-file "/var/run/named/named.pid";

};

zone "." IN {

        type hint;

        file "named.ca";

};

zone "localhost" IN {

        type master;

        file "pri/localhost";

        allow-update { none; };

        notify no;

};

zone "127.in-addr.arpa" IN {

        type master;

        file "pri/127";

        allow-update { none; };

        notify no;

};

```

/etc/resolv.conf:

```
nameserver 213.51.129.168

nameserver 213.51.144.168

search mill1.nb.home.nl

```

Maybe my firewall settings have anything to do with it:

```
iptables -A POSTROUTING -o eth0 -j MASQUERADE

iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -

iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT
```

Another thing that's strange is that I can start:

/etc/init.d/named start                      [ ok ]

but I can't stop it:

/etc/init.d/named stop	                      [ !! ]

(maybe bind or named or whatever it is called isn't running. How do I figure out if it is running? ps -AH doesn't show named or bind nor is there a pid file  :Confused:  )

/etc/conf.d/net:

```
iface_eth1="10.0.0.1 broadcast 10.0.0.255 netmask 255.255.255.0"

iface_eth0="dhcp"

dhcpcd_eth0="-N -h CP179741-A"

```

(so eth0 is connected to the ISP and eth1 to my LAN)

I also have hdcpd running, this is /etc/dhcp/dhcpd.conf:

```
ddns-update-style ad-hoc;

option domain-name "vandijklan";

subnet 10.0.0.0 netmask 255.255.255.0

{

        range 10.0.0.2 10.0.0.10;

        option subnet-mask              255.255.255.0;

        option broadcast-address        10.0.0.255;

        option domain-name-servers      10.0.0.1;

        option routers                  10.0.0.1;

}

host roel

{

        hardware ethernet 00:40:CA:BE:8B:38;

        fixed-address 10.0.0.2;

        option host-name "void";

}

host bas

{

        hardware ethernet 00:40:CA:BE:8B:DA;

        fixed-address 10.0.0.3;

        option host-name "bassbox";

}

```

When I ping www.google.com from my laptop (within my LAN) i get:

```
ping: unknown host www.google.com
```

/etc/resolv.conf of my laptop:

```
#nameserver 213.51.129.168

nameserver 10.0.0.1

search vandijklan

```

When I uncomment the first nameserver it does work of course but that's not what I want.

I just posted as much information about my networking settings as possible, so I hope somebody can help me.

thx!

----------

## Zombie[BRAAAINS]

Add the option -g to /etc/conf.d/named.conf (or maybe bind.conf, I can't remember). It'll run it in foreground and show you the error it's running into. Most likely it'll be obvious, but if not, just post it here and we'll figure it out  :Smile: 

I'm going to bed now though.

*zonk*

----------

## bassvandijk

 *Zombie[BRAAAINS] wrote:*   

> Add the option -g to /etc/conf.d/named.conf (or maybe bind.conf, I can't remember). It'll run it in foreground and show you the error it's running into. Most likely it'll be obvious, but if not, just post it here and we'll figure it out 
> 
> I'm going to bed now though.
> 
> *zonk*

 

Thx! that did the trick!!!

I had some syntax errors in /etc/bind/named.conf

----------

## syntax-terror

hi,

i think i got the same problem but named didn't told me any errors if i ran it with the -g option.

i can start named without any errors but i can't stop it.

here is the output of /etc/init.d/named start:

```
kellermuffel root # /etc/init.d/named start

 * Starting named...

Oct 10 16:19:00.790 starting BIND 9.2.2 -u named -n 1 -g

Oct 10 16:19:00.791 using 1 CPU

Oct 10 16:19:01.032 loading configuration from '/etc/bind/named.conf'

Oct 10 16:19:01.053 listening on IPv4 interface lo, 127.0.0.1#53

Oct 10 16:19:01.303 command channel listening on 127.0.0.1#953

Oct 10 16:19:01.303 ignoring config file logging statement due to -g option

Oct 10 16:19:01.381 zone 127.in-addr.arpa/IN: loaded serial 2002081601

Oct 10 16:19:01.385 zone localhost/IN: loaded serial 2002081601

Oct 10 16:19:01.386 running

```

----------

## pmjdebruijn

well, this may not be what you wanted to hear but...

Have you tried dnsmasq?

it's way easier... actually it's been designed to do nothing but to be a caching nameserver.

Regards,

DrZ

----------

## syntax-terror

that dosn't solve my problem, because in the next step i will set up a litle nameserver for my litle lan at home.

And I am interested to learn something about BIND.

----------

## Zombie[BRAAAINS]

Hmm... OK, post your named.conf and resolv.conf (on the computer you're trying to resolve with) here and we'll see what's up. Oh, and if you've made any changes to your zone files, post them too.

----------

## Chris W

bassvandijk: If you want your DNS server machine to benefit from the DNS cache you need to set it resolv.conf to point to localhost.

----------

## bassvandijk

 *Chris W wrote:*   

> bassvandijk: If you want your DNS server machine to benefit from the DNS cache you need to set it resolv.conf to point to localhost.

 

Yeas I did:

/etc/resolv.conf (of the nameserver)

```

nameserver 10.0.0.1 (my ip adress)

nameserver 213.51.144.168

search vandijklan

```

----------

## edsuom

I struggled for hours with BIND to implement a nameserver for my virtual-private server webhost, and thought that background might help me set up a simple caching-only nameserver with BIND on my Gentoo box.

Indeed it did. After only about 45 minutes of struggle this time, I searched this forum, noticed the recommendation above to use dnsmasq, ditched BIND, and did "emerge dnsmasq." Five minutes later, I'm up and running with it.   :Wink: 

----------

## AnimalMachine

OMFG! Dnsmasq is absolutely great if your goal is to set up a simple caching server! Just emerge it, run the server, and you're good to go (provided you have a valid resolv.conf ... which of course you will).

I was expecting another horrible time setting up BIND or djbdns, so this was really really great.   :Very Happy: 

----------

## dmmgentoo

 *AnimalMachine wrote:*   

> OMFG! Dnsmasq is absolutely great if your goal is to set up a simple caching server! Just emerge it, run the server, and you're good to go (provided you have a valid resolv.conf ... which of course you will).
> 
> I was expecting another horrible time setting up BIND or djbdns, so this was really really great.  

 

Bind was pretty easy to set up as a caching nameserver...  Just set the "forwarders" in /etc/bind/named.conf to point to your ISP's dns servers, add localhost as the first line in resolv.conf, and that's pretty much all there is to it.  The only problem is that named's cache isn't persistent across reboots.

----------

## ronmon

bind is overkill for a local caching dns server. It's a matter of using the right tool for the job, for which dnsmasq is much better suited.

But I don't like the dhcp server implentation in the 2.0.x branch, so I've stuck with 1.18 and am still using dhcpd.

----------

## UberLord

 *ronmon wrote:*   

> But I don't like the dhcp server implentation in the 2.0.x branch, so I've stuck with 1.18 and am still using dhcpd.

 

What's wrong with the dhcp implementation?

After using bind+dhcp I easily prefer dnsmasq.

----------

## ronmon

I guess I'm just more comfortable with dhcp. I was able to get dnsmasq's dhcp to function okay, but some of its behavior was not to my liking. It's strictly a preference thing.

----------

