# Setting up a DNS server!

## Negated Void

I've got a router type server, and it basicly runs the show for my house's networking stuff.

I want to setup a DNS server on it, so the computers on the network will look there to resolve stuff, and it'll just query my ISP for the information.

I also would like to be able to map several hosts to specific IP's, much alike setting the hosts file, only it'd affect every computer on the network.

I'm fairly sure this shouldn't be that hard, what ebuild do you guys reccomend?

Thanks very much,

-Matt

----------

## s1th

You can always start off with a BIND release (BIND 8 should suffice, you could also choose for BIND 9).

More info on BIND can be found at http://www.isc.org/products/BIND/

So, that's ebuild bind 9.2.2 (net-dns/bind).

Do not mistake this for net-dns/bind-tools since these are only the client tools for name resolving like dig, host and nslookup (nslookup = deprecated)

HTH

----------

## mkremers

You can use dnsmasq for this, it will act as a dns server on your network but it will simply look into the /etc/hosts file of the machine it runs on (the router) or use the dns of your ISP (/etc/resolve.conf) in case /etc/hosts does not contain the requested entry. Very simple to setup:

```

emerge dnsmasq

rc-update add dnsmasq default

```

If you also run a dhcp server for your network you should set the option domain-name-servers to the ip address of the router (/etc/dhcp/dhcpd.conf). If not you should specify your router as the dns on the client pc's (in /etc/resolve.conf).

----------

## WarMachine

dnsmasq works great for me, very easy to setup

----------

## adobo

can i use dnsmasq as the dns server for my domain names? 

right now i am using zoneedit as my dns server.

i have lots of virtual domains under my main domain, so i jsut have to add each of the vitrual domains in my /etc/hosts file?

thanks!

----------

## WarMachine

Although I haven't tried it I believe so

----------

## cederberg

 *adobo wrote:*   

> can i use dnsmasq as the dns server for my domain names? 
> 
> right now i am using zoneedit as my dns server.
> 
> i have lots of virtual domains under my main domain, so i jsut have to add each of the vitrual domains in my /etc/hosts file?

 

It is possible to use for an internal network, but I wouldn't recommend it if you are providing external DNS. I know too little about DNS to reason about it, but the recommendation seems to be to use different servers for authoritative DNS and caching DNS. 

A good authorative DNS server is djbdns. Dnsmasq is a caching DNS.

----------

## mekki20

Hello,

I just installed the great dnsmasq. It's just great, if it would work.   :Sad: 

I have it running on my firewall machine, also acting as gateway/route´r + dhcp-server

That's how have it setup:

- I have all hosts files on the clients left blank.

- /etc/hosts/ on FW is filled with all clientnames/ips of the clients with static ips in the network

- /etc/resolv.conf on FW is holding my two external nameservers.

- The clients DNS-Server is only the IP of the FW(192.168.0.1)

This is what I can do:

- ping any machin outside my network, e.g. www.gentoo.org

This is what I can NOT do:

- ping any machin within my network (192.168.0.0/24)

Is there a way to have more output to var/log/messages concerning dnsmasq?

Can anyone help?

M3i

 :Arrow:  Correction: I can ping some of my internal hosts. But I do NOT know why I can ping some of them and some not. And there are no hosts specified in the local /etc/hosts files of the clients.

Those hosts that are being translated to IPs are pingable from all other hosts, not just from one...I tested it.

M3i

----------

## cederberg

Weird. Sounds to me like the /etc/hosts file on your firewall is either incomplete and/or hasn't been properly loaded by dnsmasq. I assume that you can ping all hosts using their IP adresses, and that it is only the DNS lookup for some hosts that fail.

I'd try "/etc/init.d/dnsmasq restart" just to make sure all config files have been updated. Then you can always add "--log-queries" to the DNSMASQ_OPTS variable in the /etc/conf.d/dnsmasq file. See "man dnsmasq" for some other nifty options you can add in there. (I use "--bogus-priv" for my private lan, but that seems unrelated to your problems.)

----------

## mekki20

Jipp, you are right. It is "just" a DNS-problem. I can ping the local machines, through their ip-address. 

I also did a restart of 'dnsmasq' a several times. But no change.

I now have more output in /var/log/messages. But still can not figure out, why I am not getting it to work resolving my local hostnames.

I did another check and found out, that NONE of the local hostnames are not likely to be resolved. The ones I can ping are in the cache somewhere on the local machines. Damn Window$.

 :Arrow:   When I start dnsmasq with the options --no-daemon --log-querries

and do a SIGUSR1 on dnsmasq I get the listing of all cached IPs and Hostnames. There are all I want there, including the local ones from the FW's /etc/hosts file.

The only difference between the IPs from the lease-file from dhcpd and /etc/hosts are the letters in the FLAG-column of the output.

```
dnsmasq: Host                                     Address                        Flags   Expires

dnsmasq: host1                                   192.168.0.252                  4FR   D    Fri May  2 11:14:21 2003

dnsmasq: host2                                   192.168.0.116                  4FRI  H
```

So the first entry is taken out of the lease-file of the dhcpd and the 2nd entry is from /etc/hosts.

Again: I can ping 'host1', but NOT 'host2'

I don't know what to do.Last edited by mekki20 on Thu May 01, 2003 1:25 pm; edited 1 time in total

----------

## cederberg

Hmm... I think I'd try a number of diagnostic checks:

1. Verify that the DNS server IP is set to your firewall on your (Windows) clients. Maybe you should try to configure it hard if you use DHCP.

2. Run some "host <mylocalhostname> 127.0.0.1" tests on the firewall.

3. Run "tail -f /var/log/messages" to make sure your DNS requests on the clients really pass through dnsmasq.

4. Make sure you reboot the Windows machines (only way I know to be certain their caches are empty).

If everything is as it sounds, only test 2 should fail. I guess then that you'd have to look into the /etc/hosts file for some weirdness or check the dnsmasq configuration. Starting it from the command-line is probably good for debugging.

----------

## mekki20

Hi,

I just got it to work. Don't ask me, why it is working now.

I wrote Simon Kelly, the developer of dnsmasq and he wrote me back   :Wink: 

That is what he wrote:

"The cache dump is normal - the I just means that the entry is imortal - 

it will never time out. I'd start by doing testing with dig or nslookup 

rather that ping - that way you can distiguish dns problems from routing 

or host problems...."

 :Idea: 

----------

