# Local DNS server



## toml (Jan 3, 2010)

I'm trying to configure a local DNS server.  But something is wrong and I can't figure out what :\  Forwarding and cashing-nameserver seems to work. Reverse lookup is also working. 

dmesg -a :


```
Jan  3 15:14:46 bsdbox named[913]: the working directory is not writable
Jan  3 15:14:46 bsdbox named[913]: zone mydomain.local/IN: loading from master file master/mydomain-forward.db failed: unknown class/type
```

zonefile(mydomain-forward.db):


```
$TTL 3600	; 1 hour default TTL
@	IN	SOA	ns.mydomain.local. admin.mydomain.local. (
				2010010305	; Serial
				10800		; Refresh
				3600		; Retry
				604800		; Expire
				300		; Negative Reponse TTL
			)

; DNS Servers
	IN	NS	ns.mydomain.local.
	IN	A	192.168.0.100

; Machine Names
localhost	IN	A	127.0.0.1
ns		IN	A	192.168.0.100
router	IN	A	192.168.0.1
bsdbox	IN	A	192.168.0.50
```


bsdbox is the server and is correctly configured with 2 ipaddresses.
192.168.0.50 en 192.168.0.100

named.conf:


```
zone "mydomain.local" {
	type master;
	file "master/mydomain-forward.db";
};
```


----------



## SirDice (Jan 3, 2010)

toml said:
			
		

> ```
> @	IN	SOA	ns.mydomain.local. admin.mydomain.local. (
> ```



Is wrong, it should be:

```
mydomain.local IN SOA ns.mydomain.local. admin.mydomain.local. (
```


----------



## DutchDaemon (Jan 3, 2010)

I copy/pasted this zone file into my nameserver config, which found nothing at all wrong with it. It loaded the zone just fine, and queries worked too (affter allowing queries in the zone statement, that is).


```
Jan  3 16:44:00 box named[53237]: 03-Jan-2010 16:44:00.775 zone mydomain.local/IN: loaded serial 2010010305
```


----------



## DutchDaemon (Jan 3, 2010)

There's nothing wrong with the '@' part, SirDice. The domain name is derived from the zone statement in named.conf and substituted. See http://forums.freebsd.org/showthread.php?t=8259.


----------



## toml (Jan 3, 2010)

If I don't define 
[CMD="allow-query { address_match_list };"][/CMD]
all hosts are allowed to make queries, no?


----------



## toml (Jan 3, 2010)

edit:
If I don't define:


```
allow-query { address_match_list };
```

All hosts are allowed to make queries. No?


----------



## DutchDaemon (Jan 3, 2010)

It depends on which options you set at the beginning of named.conf. For zones you're serving authoritatively, you'd normally set 


```
allow-query { any; }
```

or


```
allow-query { some_acl; };
```

either in each zone, or in the options section of named.conf.

If you omit allow-query altogether, your nameserver will disallow all queries.


----------



## toml (Jan 3, 2010)

Keep getting the next error with dmesg -a

```
Jan  3 18:47:08 zodiak named[913]: the working directory is not writable
Jan  3 18:47:08 zodiak named[913]: zone cosmos.tl/IN: loading from master file dynamic/cosmos-forward.db failed: unknown class/type
```

Here al my files:

named.conf:

```
options {
	directory	"/etc/namedb";
	pid-file	"/var/run/named/pid";
	dump-file	"/var/dump/named_dump.db";
	statistics-file	"/var/stats/named.stats";

	listen-on	{ 127.0.0.1;
			  192.168.111.100;
			 };

	allow-query { 192.168.111.0/24; };

	disable-empty-zone "255.255.255.255.IN-ADDR.ARPA";
	disable-empty-zone "0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA";
	disable-empty-zone "1.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.0.IP6.ARPA";
	
	forward first;
	forwarders {
		212.71.8.10;
		212.71.0.33;
	};
};

zone "." { type hint; file "named.root"; };

// RFC 1912
zone "localhost"	{ type master; file "master/localhost-forward.db"; };
zone "127.in-addr.arpa" { type master; file "master/localhost-reverse.db"; };
zone "255.in-addr.arpa"	{ type master; file "master/empty.db"; };

// RFC 1912-style zone for IPv6 localhost address
zone "0.ip6.arpa"	{ type master; file "master/localhost-reverse.db"; };

// "This" Network (RFCs 1912 and 3330)
zone "0.in-addr.arpa"		{ type master; file "master/empty.db"; };

// Private Use Networks (RFC 1918)
zone "10.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "16.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "17.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "18.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "19.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "20.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "21.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "22.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "23.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "24.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "25.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "26.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "27.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "28.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "29.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "30.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "31.172.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "168.192.in-addr.arpa"	{ type master; file "master/empty.db"; };

// Link-local/APIPA (RFCs 3330 and 3927)
zone "254.169.in-addr.arpa"	{ type master; file "master/empty.db"; };

// TEST-NET for Documentation (RFC 3330)
zone "2.0.192.in-addr.arpa"	{ type master; file "master/empty.db"; };

// Router Benchmark Testing (RFC 3330)
zone "18.198.in-addr.arpa"	{ type master; file "master/empty.db"; };
zone "19.198.in-addr.arpa"	{ type master; file "master/empty.db"; };

// IANA Reserved - Old Class E Space
zone "240.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "241.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "242.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "243.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "244.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "245.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "246.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "247.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "248.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "249.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "250.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "251.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "252.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "253.in-addr.arpa"		{ type master; file "master/empty.db"; };
zone "254.in-addr.arpa"		{ type master; file "master/empty.db"; };

// IPv6 Unassigned Addresses (RFC 4291)
zone "1.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "3.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "4.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "5.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "6.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "7.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "8.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "9.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "a.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "b.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "c.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "d.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "e.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "0.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "1.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "2.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "3.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "4.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "5.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "6.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "7.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "8.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "9.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "a.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "b.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "0.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "1.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "2.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "3.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "4.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "5.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "6.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "7.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };

// IPv6 ULA (RFC 4193)
zone "c.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "d.f.ip6.arpa"		{ type master; file "master/empty.db"; };

// IPv6 Link Local (RFC 4291)
zone "8.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "9.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "a.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "b.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };

// IPv6 Deprecated Site-Local Addresses (RFC 3879)
zone "c.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "d.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "e.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };
zone "f.e.f.ip6.arpa"		{ type master; file "master/empty.db"; };

// IP6.INT is Deprecated (RFC 4159)
zone "ip6.int"			{ type master; file "master/empty.db"; };

zone "cosmos.local" {
	type master;
	file "master/cosmos-forward.db";
};

zone "111.168.192.in-addr.arpa" {
	type master;
	file "master/cosmos-reverse.db";
};

controls {
	inet 127.0.0.1 allow { localhost; } keys { "dnscosmoskey"; };
};

key "dnscosmoskey" {
	algorithm hmac-md5;
	secret "vHNPOW2JHoC8Th7DCgF/yV9/xmMHc7vjEYhhWPj80Qg=";
};
```

rndc.conf:

```
key "dnscosmoskey" {
	algorithm hmac-md5;
	secret "vHNPOW2JHoC8Th7DCgF/yV9/xmMHc7vjEYhhWPj80Qg=";
};

options {
	default-server 127.0.0.1;
	default-key "dnscosmoskey";
};
```

master/cosmos-forward.db:


```
$TTL 3600	; 1 hour default TTL
@	IN	SOA	ns.cosmos.local. admin.cosmos.local. (
				2010010306	; Serial
				10800		; Refresh
				3600		; Retry
				604800		; Expire
				300		; Negative Reponse TTL
			)

; DNS Servers
	IN	NS	ns.cosmos.local.
	IN	A	192.168.111.100

; Machine Names
localhost	IN	A	127.0.0.1
ns		IN	A	192.168.111.100
zodiak		IN	A	192.168.111.50
router		IN	A	192.168.111.254
switch		IN	A	192.168.111.1
airport1	IN	A	192.168.111.2
airport2	IN	A	192.168.111.3

: Aliases
www	IN	CNAME	zodiak
```

/master/cosmos-reverse.db:

```
$TTL 3600	; 1 hour default TTL
@	IN	SOA	ns.cosmos.local. admin@cosmos.local. (
				2010010302	; Serial
				10800		; Refresh
				3600		; Retry
				604800		; Expire
				300		; Negative Reponse TTL
				)

; DNS Servers
	IN	NS	ns.cosmos.local.

; Pointers
100	IN	PTR	ns.cosmos.local.	
50	IN	PTR	zodiak.cosmos.local.
1	IN	PTR	switch.cosmos.local.
2	IN	PTR	airport1.cosmos.local.
3	IN	PTR	airport2.sosmos.local.
```

etc/rc.conf:

```
hostname="zodiak.m5t.local"
ifconfig_sk0="up"
ifconfig_ale0="up"
cloned_interfaces="lagg0"
ifconfig_lagg0="laggproto lacp laggport sk0 laggport ale0"
ipv4_addrs_lagg0="192.168.111.50/24 192.168.111.100/24 192.168.111.110/24"
defaultrouter="192.168.111.254"
hostname="zodiak.cosmos.tl"
keymap="be.iso"
sshd_enable="YES"
dhcpd_enable="YES"
dhcpd_ifaces="lagg0"
named_enable="YES"
```


----------



## DutchDaemon (Jan 3, 2010)

Ok, one of the more annoying things of BIND is that it prints the first error message it encounters, but that error message can be caused by something earlier in named.conf. Can you try making the zone that triggers the error your very first zone (right below the root zone)?

Oh, and where does this come from?


```
cosmos.[B][color="Red"]tl[/color][/B]/IN
```


----------



## toml (Jan 3, 2010)

Where 
	
	



```
cosmos.tl/IN
```
 came from I don't know, but it isn't there anymore. I deleted all the zone files that I didn't need to test of zone "cosmos.local" works. So my named.conf looked like:

```
options {
	directory	"/etc/namedb";
	pid-file	"/var/run/named/pid";
	dump-file	"/var/dump/named_dump.db";
	statistics-file	"/var/stats/named.stats";

	listen-on	{ 127.0.0.1;
			  192.168.111.100;
			 };
	
	allow-transfer { none; };
	allow-query { localnets; };
	allow-recursion { localnets; };

	forward first;
	forwarders {
		212.71.8.10;
		212.71.0.33;
	};
};

zone "." { type hint; file "named.root"; };

zone "cosmos.local" {
	type master;
	file "master/cosmos-forward.db";
};

zone "111.168.192.in-addr.arpa" {
	type master;
	file "master/cosmos-reverse.db";
};

controls {
	inet 127.0.0.1 allow { localhost; } keys { "dnscosmoskey"; };
};

key "dnscosmoskey" {
	algorithm hmac-md5;
	secret "vHNPOW2JHoC8Th7DCgF/yV9/xmMHc7vjEYhhWPj80Qg=";
};
```

but still dmesg -a:

```
Jan  3 20:10:21 zodiak named[913]: the working directory is not writable
Jan  3 20:10:21 zodiak named[913]: zone cosmos.local/IN: loading from master file master/cosmos-forward.db failed: unknown class/type
```


----------



## DutchDaemon (Jan 3, 2010)

```
[color="Red"]:[/color] Aliases
www	IN	CNAME	zodiak
```

Get rid of the colon there, should be a semi-colon.

By the way, why are you reading errors from `dmesg -a`? You are not rebooting your server every single time, I hope? Just use `# /etc/rc.d/named restart`.


----------



## toml (Jan 3, 2010)

P Thanks, stupid typo, could hit myself with a hammer 
	

	
	
		
		

		
			





No, I amnot rebooting everytime, am using rndc reload

Anyway thanks a lot!


----------

