regex for dns update

Nicolas C. dhcp at
Tue May 8 19:34:43 UTC 2012

On 02/05/2012 13:58, Tom Schmitt wrote:
> Hi,
> my dhcpd is sending DNS-updates to the DNS server when a lease is given to a dhcp client with the name the dhcp client is providing.
> Now I want this only if the name is following a given pattern, something like:
> if($clientname=~/^[A-Za-z]{4}\d{4}$/) {
>       send_dns_update;
> }
> else {
>       dont_send_a_dns_update;
> }
> Can anyone tell me, what the syntax is to configure this on a global scope in dhcpd.conf?


I haven't tried in the global scope, but I've put this in a separate 
file, and I include it where I need :

if (exists host-name and option host-name ~~ 
"^[a-z0-9][a-z0-9-]*[a-z0-9]$") {
		set ddns-hostname = option host-name;
	} else {
		set ddns-hostname = concat("dhcp", "-",
			binary-to-ascii(10, 8, "-", leased-address));

With this regex, the hostname has to be at least 2 chars long and it 
cannot start or/and end with "-".

The "~~" operator isn't case-sensitive so you don't have to match 
uppercase letters.



More information about the dhcp-users mailing list