# DDNS with dhcpd and bind



## Ajax (Jan 16, 2012)

Hello everyone,

After I tried options below to generate dynamic host names, I cannot get rid of their effect anymore! Tried to stop both DHCPd and NAMEd, trash lease and *.jnl files but still getting hostnames like dhcp-10-20-30-40.DOMAIN.COM

```
ddns-hostname = pick (option fqdn.hostname, option host-name, concat ("dhcp-", binary-to-ascii (10, 8, "-", leased-address)));
option host-name = config-option server.ddns-hostname;
```

Moreover, nslookup for both â€” generated (dhcp-10-20-30-40.DOMAIN.COM) and manually assigned (wifi-airport.DOMAIN.COM) returns me valid address!

Here is the current content of /usr/local/etc/dhcpd.conf.

```
subnet 10.20.30.0 netmask 255.255.255.0 {
	# We need static declarations only.
	range 10.20.30.189 10.20.30.189;

	authoritative;
	ddns-update-style interim;
	option broadcast-address 10.20.30.255;
	option domain-name "DOMAIN.COM";
	option domain-name-servers ns1.DOMAIN.COM, ns2.DOMAIN.COM;
	option netbios-scope "";
	option routers 10.20.30.1;
	update-static-leases on;

	group {

		use-host-decl-names on;

		key DHCP_UPDATER {
			algorithm HMAC-MD5;
			secret <SECRET-GOES-HERE-W/O-QUOTES>;
		};

		zone DOMAIN.COM. {
			primary 127.0.0.1;
			key DHCP_UPDATER;
		}

		zone 30.20.10.in-addr.arpa {
			primary 127.0.0.1;
			key DHCP_UPDATER;
		}	

		default-lease-time 3600;#14400
		max-lease-time 7200;#28800

		# wireless points
		host wifi-airport	{ hardware ethernet aa:bb:cc:dd:ee:ff; fixed-address 10.20.30.40; }
		â€¦ other definitions â€¦
	}
	deny unknown-clients;
}
```


----------



## SirDice (Jan 16, 2012)

Make sure the client has a correct *hostname* configured in /etc/rc.conf.


```
dice@williscorto:~>grep ifconfig /etc/rc.conf
ifconfig_re0="DHCP"
ifconfig_re0_ipv6="inet6 accept_rtadv"
dice@williscorto:~>grep hostname /etc/rc.conf
hostname="williscorto.dicelan.home"
dice@williscorto:~>host williscorto
williscorto.dicelan.home has address 192.168.100.20
```


----------



## Ajax (Jan 16, 2012)

Wellâ€¦ clients are Ma computers, most of them do have hostnames configure. Moreover I'm doing hostname <HOST> on a client but after lease expired and Mac got new packet, I'm receiving auto-generated one again  But if my dhcpd.conf is correct at all?


----------



## SirDice (Jan 16, 2012)

Here's my working one:

```
option domain-name "dicelan.home.";
option domain-name-servers 192.168.100.1;
option ntp-servers 192.168.100.1;

default-lease-time 600;
max-lease-time 7200;
authoritative;
ddns-update-style interim;
log-facility local7;
ignore client-updates;
#ddns-ttl 600;

do-forward-updates true;

key DHCP {
        algorithm HMAC-MD5;
        secret "<SECRET>";
}

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

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

subnet 192.168.100.0 netmask 255.255.255.0 {
        range 192.168.100.20 192.168.100.100;
        option routers 192.168.100.1;
}
```


----------

