# How can I cache my dns requests?

## neeyo

Is there a way that I can either use my own machine as a dns server or simply store all the dns requests that my pc makes to my isp? My dns server for my isp has been a little sluggish lately, and there's really no point in requesting the ip for the same domain 5 times in a row, know what I mean?

----------

## Larde

Hi!

 *Quote:*   

> Is there a way that I can either use my own machine as a dns server or simply store all the dns requests that my pc makes to my isp?

 

I'd strongly suggest dnscache from the djbdns package for this. It does both, it will resolve requests independent from your ISP's DNS server, and cache the results.

You'll have to be good at reading documentation though, and the djbdns mailing list is not really friendly to people asking "stupid" questions. Have a look at http://lifewithdjbdns.org/ if you are interested in it.

Yours,

Larde.

P.S. Actually, just using dnscache is really easy to setup. The whole package might be another topic, especially when you are only used to BIND.  :Smile: 

----------

## dioxmat

also check out /usr/portage/net-dns/ :)

----------

## Chris W

The default BIND ebuild configuration seems to be setup for a simple caching-only arrangement.

Perhaps uncomment the /etc/bind/named.conf lines:

```
        // to allow only specific hosts to use the DNS server:

        //allow-query {

        //      127.0.0.1;

        //};
```

 to restrict access to the server.

There's more here although it is not Gentoo specific.

----------

## zypher

I really recommend dnsmasq http://thekelleys.org.uk/dnsmasq/doc.html

No need for anything else.

I use this tool for a long time now and I am really impressed and pleased by the ease of installation and configuration.

Always wanted to do an ebuild, but was too busy to read a howto (hint).

hth,

zypher

----------

## dioxmat

```

[mat.garbage.pts/2: ~]% emerge -s dnsmasq

Searching...   

[ Results for search key : dnsmasq ]

[ Applications found : 1 ]

 

*  net-dns/dnsmasq

      Latest version Available: 1.6

      Latest version Installed: [ Not Installed ]

      Homepage: http://www.thekelleys.org.uk/dnsmasq/

      Description: Proxy DNS server

 

[mat.garbage.pts/2: ~]%

```

:)

----------

## klieber

moving to networking forum.

--kurt

----------

## SNo0py

Hm... I've installed dnsmasq, it is working fine, I can nslookup all hosts within the /etc/hosts and within the internet.

But if I'm trying to ping, there happens something mysterious. I can ping every host within the Internet, but I can't ping any host within my /etc/hosts-table...  :Sad: 

ping:

```
Ping request could not find host bruce. Please check the name and try again.
```

nslookup:

```
Server:  bruce

Address:  192.168.1.1

Non-authoritative answer:

Name:    bruce

Address:  192.168.1.1
```

Any ideas?

----------

## Larde

Do you have something like

```
hosts:       files dns
```

in your /etc/nsswitch.conf? That means: Look up hosts first in /etc/hosts, then in dns.

edit: Ooops, sorry, you actually can lookup your own hosts, just not ping then? That's strange. Then it should be some other problem. bugger...

btw: Is that some special incarnation of ping? I've never seen the error message you quoted before.

Regards,

Larde.

----------

## SNo0py

 *Larde wrote:*   

> 
> 
> btw: Is that some special incarnation of ping? I've never seen the error message you quoted before.
> 
> 

 

Its a very, very strange incarnation of ping - its delivered with Win** XP   :Very Happy: 

And a nslookup is returning the right adresses (intra+internet) but ping, ssh, samba... are not resolving the intranet-adresses - "Hostname not found"...  :Sad: 

----------

## Larde

Hmm, I just read the docs to dnsmasq now, and you are correct, it should work as you expect.

The nslookup that is working is also done on the XP box? Hmm, I would think it's Windows problem then, I can happily step away...  :Smile: 

But: does dnsmasq write some sort of logfiles? Are the request coming when using nslookup but not when using ping?

I just asked our Windows guy: The easiest work around would be to use the lmhost file on the Windows machines, but probably you don't want to do that. He further said something about not being a dns problem, but a netbios problem, and using commands like "nbtstat" and some other things. But we both really have a different terminology sometimes, I have have no idea if we were talking about the same thing.  :Smile: 

Yours,

Larde.

----------

## SNo0py

Thanx for your answer, I'll look up the logfiles if I find them  :Wink: 

@lmhost: the file is named hosts and I'm using dnsmasq because I don't want to update this file on every Box within my net... I'd like to maintain only the hosts-file on the Gateway with dnsmasq...

thx, cu!

----------

## klieber

 *Larde wrote:*   

> He further said something about not being a dns problem, but a netbios problem

 

This is, in fact, the problem.  When you ping a non-FQDN on a Winders box, it assumes it's a netbios name and ignores DNS completely.  (this may be different if you're connected to a Win2K domain, but I'm not sure)

So, there are two fixes:

Put an entry in your %windows%\system32\drivers\etc\lmhosts file

Access the servers from your WinXP box by using a FQDN -- "bruce.foo.com" instead of just "bruce"

--kurt

----------

## klieber

Quick follow up.  There's also a way to adjust the resolution order on windows boxes.  This might allow you to place DNS as the primary choice, with hosts and lmhosts files being secondary choices.  It's a registry setting somewhere, I believe -- search Microsoft's knowledge base or google for more info.

--kurt

----------

## SNo0py

Thanx, I'll try and post an answer!

M.

----------

