# Dynamic DNS problem



## NCDDM (Jan 25, 2012)

Hi, I'm having problems to configure the dynamic DNS on my server. I`m using freebsd FreeBSD 8.2, BIND and isc-dhcp41-server.

The configuration files are:

DNS configuration:

/var/named/etc/namedb

```
dhcp1# ls -la

drwxr-xr-x  6 root  wheel    512 Jan 23 19:49 .
drwxr-xr-x  3 root  wheel    512 Jan 23 19:49 ..
drwxr-xr-x  2 bind  wheel    512 Feb 16  2011 dynamic
drwxr-xr-x  2 root  wheel    512 Jan 23 19:47 master
-rw-r--r--  1 root  wheel    814 Jan 23 19:50 named.conf
-rw-r--r--  1 root  wheel  13982 Feb 16  2011 named.conf_samples
-rw-r--r--  1 root  wheel   3085 Feb 16  2011 named.root
-rw-------  1 bind  wheel     97 Jan 23 19:49 rndc.key
drwxr-xr-x  2 bind  wheel    512 Feb 16  2011 slave
drwxr-xr-x  2 bind  wheel    512 Feb 16  2011 working
```
`vi /var/named/etc/namedb/named.conf`

```
zone "test.com.ar" {
        type master;
        allow-update {any;};
        also-notify {192.1.10.2;};
        ixfr-from-differences yes;
        allow-transfer {192.1.10.2;};
        file "/etc/namedb/master/test.db";
};
```
/var/named/etc/namedb/master

```
dhcp1# ls -la
drwxr-xr-x  2 root  wheel   512 Jan 23 19:47 .
drwxr-xr-x  6 root  wheel   512 Jan 23 19:49 ..
-rwxrwxrwx  1 root  wheel  1832 Jan 23 19:46 test.db
-rwxrwxrwx  1 root  wheel   243 Feb 16  2011 empty.db
-rwxrwxrwx  1 root  wheel   265 Feb 16  2011 localhost-forward.db
-rwxrwxrwx  1 root  wheel   333 Feb 16  2011 localhost-reverse.db
```
`vi /var/named/etc/namedb/master/test.db`

```
$TTL 3600        ; 1 hour default TTL
test.com.ar.    		IN      SOA     dns1.test.com.ar. root.localhost. (
                                	2006051503      ; Serial
                                	200             ; Refresh
                                	200             ; Retry
                                	604800          ; Expire
                                	300             ; Negative Response TTL
                       		)

                		NS              dns1.test.com.ar.
                		A               200.49.210.5

; Machine Names

test1		A       10.0.0.5
test2    	        	A       10.0.0.6
test3        	A       10.0.0.7
```

DHCP configuration:

```
dhcp1# cd /usr/local/etc/
dhcp1# ls -la

drwxr-xr-x   6 root  wheel   512 Jan 23 19:40 .
drwxr-xr-x  13 root  wheel   512 Jan 23 16:19 ..
drwxr-xr-x   2 root  wheel   512 Jan 23 16:19 devd
-rw-r--r--   1 root  wheel   506 Jan 23 19:40 dhcpd.conf
drwxr-xr-x   2 root  wheel   512 Jan 23 16:19 man.d
drwxr-xr-x   2 root  wheel   512 Jan 23 16:19 pam.d
drwxr-xr-x   2 root  wheel   512 Jan 23 19:31 rc.d
```
`vi dhcpd.conf`

```
ddns-domainname "dialdata.com.ar.";
ddns-rev-domainname "in-addr.arpa.";
ddns-update-style interim;
allow client-updates;
option domain-name "dialdata.com.ar";
option domain-name-servers 192.1.10.1, 192.1.10.2;

authoritative;
log-facility local7;

subnet 192.1.0.0 netmask 255.255.0.0 {
  range 192.1.50.2 192.1.50.40;
  option routers 192.1.1.1;
  default-lease-time 600;
  max-lease-time 7200;

zone dialdata.com.ar. {
  primary 127.0.0.1;
  }

zone 50.1.192.in-addr.arpa. {
  primary 127.0.0.1;
  }

}
```
Problem: named is not configuring the DNS entries received from the dhcp. Named is not able to create the .jnl files and it is not able to map the hostnames.


```
dhcp1# vi /var/log/messages

Jan 25 13:16:28 dhcp1 named[579]: /etc/namedb/master/test.db.jnl: create: permission denied
Jan 25 13:16:28 dhcp1 dhcpd: Unable to add forward map from ubuntu.test.com.ar. to 192.1.50.4: timed out
Jan 25 13:16:29 dhcp1 named[579]: /etc/namedb/master/test.db.jnl: create: permission denied
Jan 25 13:16:29 dhcp1 dhcpd: Unable to add forward map from ubuntu.test.com.ar. to 192.1.50.3: timed out
```
I tried to solve this issue changing the files permissions and the file owner without success.
I hope that you can help me.

Thanks in advance.


----------



## SirDice (Jan 25, 2012)

You really need to use keys.

In named.conf:

```
key DHCP {
        algorithm HMAC-MD5;
        secret "SomeSecretKey";
};
        zone "dicelan.home." {
                type master;
                notify no;
                file "/etc/namedb/dynamic/dicelan.home";
                allow-update { 127.0.0.1; key DHCP; };
        };

        zone "100.168.192.in-addr.arpa." {
                type master;
                notify no;
                file "/etc/namedb/dynamic/100.168.192.in-addr.arpa";
                allow-update { 127.0.0.1; key DHCP; };
        };
```
In dhcpd.conf:

```
ddns-update-style interim;
ignore client-updates;
do-forward-updates true;

key DHCP {
        algorithm HMAC-MD5;
        secret "SomeSecretKey";
}

zone dicelan.home. {
        primary 127.0.0.1;
        key DHCP;
}

zone 100.168.192.in-addr.arpa. {
        primary 127.0.0.1;
        key DHCP;
}
```

Make sure both DHCP and DNS are configured with the same key. Also note you need to use the /etc/named/dynamic/ directory as BIND needs to be able to write.


----------



## NCDDM (Jan 25, 2012)

Thanks SirDice for your reply.

I added the keys to the conf files and move the conf files to /etc/named/dynamic.
Now bind is creating the .jnl files but it is not updating the zone db.
I`m receiving the following error message on the log file:


```
Jan 25 19:15:17 dhcp1 dhcpd: Forward map from ubuntu.test.com.ar. to 192.1.50.3 FAILED: Has an address record but no DHCID, not mine.
```


/var/named/etc/namedb/named.conf


```
key DHCP {
        algorithm HMAC-MD5;
        secret "PASS";
};


zone "test.com.ar" {
        type master;
        allow-update {any; key DHCP;};
        also-notify {192.1.10.2;};
        ixfr-from-differences yes;
        file "/etc/namedb/dynamic/test.db";
};


zone "50.1.192.in-addr.arpa" {
        type master;
        allow-update {any; key DHCP;};
        also-notify {192.1.10.2;};
        ixfr-from-differences yes;
        file "/etc/namedb/dynamic/X.50.1.192.db";
};
```


```
dhcp1# pwd
/var/named/etc/namedb/dynamic

drwxr-xr-x  2 bind  wheel   512 Jan 25 18:58 .
drwxr-xr-x  6 root  wheel   512 Jan 25 18:25 ..
-rw-r--r--  1 root  wheel   316 Jan 25 18:23 X.50.1.192.db
-rw-r--r--  1 bind  wheel   777 Jan 25 18:45 X.50.1.192.db.jnl
-rw-r--r--  1 bind  wheel  1756 Jan 25 18:57 test.db
-rw-r--r--  1 bind  wheel   817 Jan 25 18:45 test.db.jnl
```


```
/usr/local/etc

-rw-r--r--   1 root  wheel   596 Jan 25 19:12 dhcpd.conf
```


```
dhcp1# vi dhcpd.conf

ddns-domainname "test.com.ar.";
ddns-rev-domainname "in-addr.arpa.";
ddns-update-style interim;
allow client-updates;
option domain-name "test.com.ar";
option domain-name-servers 192.1.10.1, 192.1.10.2;

authoritative;
log-facility local7;

subnet 192.1.0.0 netmask 255.255.0.0 {
  range 192.1.50.2 192.1.50.40;
  option routers 192.1.1.1;
  default-lease-time 600;
  max-lease-time 7200;

key DHCP {
        algorithm HMAC-MD5;
        secret "PASS";
}

zone test.com.ar. {
  primary 127.0.0.1;
  key DHCP;
  }

zone 50.1.192.in-addr.arpa. {
  primary 127.0.0.1;
  key DHCP;
  }

}
```


----------



## DutchDaemon (Jan 25, 2012)

Don't dump unformatted output here, thanks -> http://forums.freebsd.org/showthread.php?t=8816


----------



## SirDice (Jan 26, 2012)

NCDDM said:
			
		

> I`m receiving the following error message on the log file:
> 
> 
> ```
> ...



That means it already has a record but since it can't find the correct ID it can't update that record.

We first need to stop BIND from updating:
`# rndc freeze`
Now edit the zone file and remove that offending record. Don't forget to also update the zone's serial number.

And allow updates again:
`# rndc unfreeze`

Then restart your client and it should register properly.


----------



## NCDDM (Jan 26, 2012)

Thanks again for the reply. Now I see the entries on the zone db, but it is not working automatically, I must freeze rndc and then unfreeze it. An other problem that I have, is that I cannot ping the host.

After the dhcp assigns an IP to the client I freeze rndc and then I unfreeze it.


```
dhcp1# rndc freeze
dhcp1# rndc unfreeze
```

Once rndc is unfreezed I can see the new entry on the zone db but the hostnmae.


```
dhcp1# vi test.db

ubuntu                  A       192.1.50.4
                        TXT     "00ea0f5fa459bc641639e8c9ff3a29b3af"

dhcp1# ping ubuntu.test.com.ar
ping: cannot resolve ubuntu.test.com.ar: Unknown host
```

Here you can see the logs:


```
dhcp1# vi /var/log/messages

Jan 26 12:15:02 dhcp1 named[584]: zone test.com.ar/IN: ixfr-from-differences: new serial (2006051513) out of range [2006051514 - 4153535160]
Jan 26 12:15:02 dhcp1 named[584]: zone test.com.ar/IN: not loaded due to errors.
Jan 26 12:15:02 dhcp1 named[584]: zone 50.1.192.in-addr.arpa/IN: ixfr-from-differences: new serial (2007040308) out of range [2007040309 - 4154523955]
Jan 26 12:15:02 dhcp1 named[584]: zone 50.1.192.in-addr.arpa/IN: not loaded due to errors.
```


----------



## SirDice (Jan 26, 2012)

You only need to 'freeze' the zones if you edit them by hand. But I think you incorrectly updated the serial number. I usually use the date as in "2012 01 26 001" without the spaces. And for every time you edit the zone add 1, so you get 002, 003, etc. at the end.

As for resolving, make sure your /etc/resolv.conf is correctly pointing to your DNS server.


----------

