Host-decl-name not working and vyos adding dhcp server name prefix to static leases

Hi I am on 1.5-rolling-202310090023

I am trying to add host-decl-macro on the dhcp server and it keeps failing.

vyos@router# set service dhcp-server host-decl-name
[edit]
vyos@router# commit;save;

Configuration file errors encountered - check your options!

[[service dhcp-server]] failed
Commit failed
Warning: you have uncommitted changes that will not be saved.

[edit]

My dhcp server config in /config/config.boot looks like,

        shared-network-name vlan50 {
            authoritative
            domain-name "home.arpa"
            domain-search "home.arpa"
            name-server "10.0.99.14"
            ntp-server "10.0.50.1"
            subnet 10.0.50.0/24 {
                default-router "10.0.50.1"
                lease "43200"
                range vlan50 {
                    start "10.0.50.30"
                    stop "10.0.50.50"
                }
                static-mapping caddy {
                    ip-address "10.0.50.3"
                    mac-address "fe:dc:29:20:67:50"
                }
            }
        }

and vyos outputs a dhcpd config that looks like

shared-network vlan50 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.50.1;
    subnet 10.0.50.0 netmask 255.255.255.0 {
        option routers 10.0.50.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host vlan50_caddy {
            fixed-address 10.0.50.3;
            hardware ethernet fe:dc:29:20:67:50;
        }
        pool {
            range 10.0.50.30 10.0.50.50;
        }
    }
    on commit {
        set shared-networkname = "vlan50";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

Please let me know how can I fix this ?

Once you commit, and you get the error, please share full content of file /run/dhcp-server/dhcpd.conf

Here it is, the full config.

dhcpd.txt (534 Bytes)

I think you uploaded the wrong file…

Yeah, sorry.

here is the full config

### Autogenerated by dhcp_server.py ###

# For options please consult the following website:
# https://www.isc.org/wp-content/uploads/2017/08/dhcp43options.html
#
# log-facility local7;
on release {
    set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name);
    set ClientIp = binary-to-ascii(10, 8, ".",leased-address);
    execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", "", ClientIp, "", "");
}
on expiry {
    set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name);
    set ClientIp = binary-to-ascii(10, 8, ".",leased-address);
    execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", "", ClientIp, "", "");
}


ddns-update-style none;
option rfc3442-static-route code 121 = array of integer 8;
option windows-static-route code 249 = array of integer 8;
option wpad-url code 252 = text;
option rfc8925-ipv6-only-preferred code 108 = unsigned integer 32;

# Vendor specific options - Ubiquiti Networks
option space ubnt;
option ubnt.unifi-controller code 1 = ip-address;
class "ubnt" {
    match if substring (option vendor-class-identifier , 0, 4) = "ubnt";
    option vendor-class-identifier "ubnt";
    vendor-option-space ubnt;
}


# Shared network configration(s)
shared-network vlan10 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.10.1;
    subnet 10.0.10.0 netmask 255.255.255.0 {
        option domain-name-servers 10.0.99.14;
        option routers 10.0.10.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host vlan10_ESP-0D4C7B {
            fixed-address 10.0.10.20;
            hardware ethernet 24:a1:60:0d:4c:7b;
        }
        host vlan10_ha {
            fixed-address 10.0.10.18;
            hardware ethernet 3e:f1:c0:4d:c9:c7;
        }
        host vlan10_wlan0 {
            fixed-address 10.0.10.23;
            hardware ethernet 38:1f:8d:39:8e:06;
        }
        pool {
            range 10.0.10.10 10.0.10.50;
        }
    }
    on commit {
        set shared-networkname = "vlan10";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan20 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.20.1;
    subnet 10.0.20.0 netmask 255.255.255.0 {
        option routers 10.0.20.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.20.10 10.0.20.50;
        }
    }
    on commit {
        set shared-networkname = "vlan20";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan30 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.30.1;
    subnet 10.0.30.0 netmask 255.255.255.0 {
        option routers 10.0.30.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.30.10 10.0.30.50;
        }
    }
    on commit {
        set shared-networkname = "vlan30";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan40 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.40.1;
    subnet 10.0.40.0 netmask 255.255.255.0 {
        option routers 10.0.40.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.40.10 10.0.40.50;
        }
    }
    on commit {
        set shared-networkname = "vlan40";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan50 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.50.1;
    subnet 10.0.50.0 netmask 255.255.255.0 {
        option routers 10.0.50.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host vlan50_arr {
            fixed-address 10.0.50.16;
            hardware ethernet da:0e:0d:8f:05:3b;
        }
        host vlan50_caddy {
            fixed-address 10.0.50.3;
            hardware ethernet fe:dc:29:20:67:50;
        }
        host vlan50_deluge {
            fixed-address 10.0.50.14;
            hardware ethernet d6:7b:d0:98:d6:2b;
        }
        host vlan50_garage {
            fixed-address 10.0.50.17;
            hardware ethernet f6:3c:40:0d:11:23;
        }
        host vlan50_gitea {
            fixed-address 10.0.50.20;
            hardware ethernet fe:2f:15:b3:9d:6d;
        }
        host vlan50_grafana {
            fixed-address 10.0.50.12;
            hardware ethernet 0a:0e:01:16:f9:4c;
        }
        host vlan50_influxdb {
            fixed-address 10.0.50.8;
            hardware ethernet f6:f7:3b:35:0a:c4;
        }
        host vlan50_jackett {
            fixed-address 10.0.50.21;
            hardware ethernet 1a:21:50:59:54:ee;
        }
        host vlan50_jellyfin {
            fixed-address 10.0.50.11;
            hardware ethernet 42:83:00:ba:47:96;
        }
        host vlan50_lldap {
            fixed-address 10.0.50.18;
            hardware ethernet 92:6c:f5:91:f4:bd;
        }
        host vlan50_mariadb {
            fixed-address 10.0.50.6;
            hardware ethernet 4a:05:ee:aa:42:50;
        }
        host vlan50_nas {
            fixed-address 10.0.50.10;
            hardware ethernet ce:35:69:50:4c:95;
        }
        host vlan50_paperless {
            fixed-address 10.0.50.15;
            hardware ethernet b6:81:3c:6b:36:d1;
        }
        host vlan50_postgres {
            fixed-address 10.0.50.7;
            hardware ethernet 3a:05:ee:aa:42:50;
        }
        host vlan50_syslog {
            fixed-address 10.0.50.9;
            hardware ethernet 0e:23:43:84:74:6c;
        }
        host vlan50_thelounge {
            fixed-address 10.0.50.13;
            hardware ethernet 8a:90:17:27:04:a3;
        }
        host vlan50_vscode {
            fixed-address 10.0.50.22;
            hardware ethernet 8a:df:13:1b:fd:8e;
        }
        pool {
            range 10.0.50.30 10.0.50.50;
        }
    }
    on commit {
        set shared-networkname = "vlan50";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan60 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.60.1;
    subnet 10.0.60.0 netmask 255.255.255.0 {
        option routers 10.0.60.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.60.10 10.0.60.50;
        }
    }
    on commit {
        set shared-networkname = "vlan60";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan70 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.70.1;
    subnet 10.0.70.0 netmask 255.255.255.0 {
        option routers 10.0.70.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host vlan70_Clinic {
            fixed-address 10.0.70.13;
            hardware ethernet ec:71:db:5e:1d:6e;
        }
        host vlan70_EPSON1E715E {
            fixed-address 10.0.70.14;
            hardware ethernet f8:d0:27:1e:71:5e;
        }
        host vlan70_Outdoors {
            fixed-address 10.0.70.11;
            hardware ethernet ec:71:db:61:0b:71;
        }
        host vlan70_Road {
            fixed-address 10.0.70.12;
            hardware ethernet ec:71:db:ab:5c:c2;
        }
        host vlan70_cups {
            fixed-address 10.0.70.7;
            hardware ethernet 3a:c1:ee:aa:42:70;
        }
        host vlan70_mariadb {
            fixed-address 10.0.70.6;
            hardware ethernet 4a:05:ee:aa:42:70;
        }
        host vlan70_shinobi {
            fixed-address 10.0.70.10;
            hardware ethernet 6e:75:53:30:80:1e;
        }
        host vlan70_syslog {
            fixed-address 10.0.70.9;
            hardware ethernet 7e:f9:bf:18:60:36;
        }
        pool {
            range 10.0.70.10 10.0.70.50;
        }
    }
    on commit {
        set shared-networkname = "vlan70";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan99 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.99.1;
    subnet 10.0.99.0 netmask 255.255.255.0 {
        option routers 10.0.99.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host vlan99_EAP245-60-A4-B7-47-8E-94 {
            fixed-address 10.0.99.2;
            hardware ethernet 60:a4:b7:47:8e:94;
        }
        host vlan99_EAP660-HD-50-91-E3-C6-18-C6 {
            fixed-address 10.0.99.5;
            hardware ethernet 50:91:e3:c6:18:c6;
        }
        host vlan99_Openwrt-AP2 {
            fixed-address 10.0.99.4;
            hardware ethernet d8:07:b6:b4:7e:9e;
        }
        host vlan99_Openwrt-AP4 {
            fixed-address 10.0.99.12;
            hardware ethernet 10:27:F5:7D:AF:A7;
        }
        host vlan99_TL-SG2210MP {
            fixed-address 10.0.99.7;
            hardware ethernet 00:31:92:76:47:39;
        }
        host vlan99_TL-SG2210P {
            fixed-address 10.0.99.11;
            hardware ethernet b4:b0:24:98:0c:fa;
        }
        host vlan99_adguardhome {
            fixed-address 10.0.99.14;
            hardware ethernet 2a:05:ee:40:42:99;
        }
        host vlan99_omada {
            fixed-address 10.0.99.16;
            hardware ethernet 72:bc:48:bd:7f:cc;
        }
        host vlan99_pvenas {
            fixed-address 10.0.99.9;
            hardware ethernet a8:a1:59:b7:de:5f;
        }
        host vlan99_syslog {
            fixed-address 10.0.99.13;
            hardware ethernet 4a:9e:f4:1f:cd:de;
        }
        pool {
            range 10.0.99.20 10.0.99.50;
        }
    }
    on commit {
        set shared-networkname = "vlan99";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan150 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.150.1;
    subnet 10.0.150.0 netmask 255.255.255.0 {
        option routers 10.0.150.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.150.10 10.0.150.50;
        }
    }
    on commit {
        set shared-networkname = "vlan150";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan160 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.160.1;
    subnet 10.0.160.0 netmask 255.255.255.0 {
        option routers 10.0.160.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.160.10 10.0.160.50;
        }
    }
    on commit {
        set shared-networkname = "vlan160";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

hey does any one have any solution to this issue ?

Setting host-decl-name should fix this problem but vyos is not letting me save the config with this parameter set!

After setting this parameter and committing changes, It generates a temporary file at /tmp/dhcpd.conf.
That file looks like this,

### Autogenerated by dhcp_server.py ###

# For options please consult the following website:
# https://www.isc.org/wp-content/uploads/2017/08/dhcp43options.html
#
# log-facility local7;
on release {
    set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name);
    set ClientIp = binary-to-ascii(10, 8, ".",leased-address);
    execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", "", ClientIp, "", "");
}
on expiry {
    set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name);
    set ClientIp = binary-to-ascii(10, 8, ".",leased-address);
    execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "release", "", ClientIp, "", "");
}

use-host-decl-names on;
ddns-update-style none;
option rfc3442-static-route code 121 = array of integer 8;
option windows-static-route code 249 = array of integer 8;
option wpad-url code 252 = text;
option rfc8925-ipv6-only-preferred code 108 = unsigned integer 32;

# Vendor specific options - Ubiquiti Networks
option space ubnt;
option ubnt.unifi-controller code 1 = ip-address;
class "ubnt" {
    match if substring (option vendor-class-identifier , 0, 4) = "ubnt";
    option vendor-class-identifier "ubnt";
    vendor-option-space ubnt;
}

# The following 1 line(s) have been added as
# global-parameters in the CLI and have not been validated !!!
use-host-decl-names on;


# Shared network configration(s)
shared-network vlan10 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.10.1;
    subnet 10.0.10.0 netmask 255.255.255.0 {
        option domain-name-servers 10.0.99.14;
        option routers 10.0.10.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host ESP-0D4C7B {
            fixed-address 10.0.10.20;
            hardware ethernet 24:a1:60:0d:4c:7b;
        }
        host ha {
            fixed-address 10.0.10.18;
            hardware ethernet 3e:f1:c0:4d:c9:c7;
        }
        host wlan0 {
            fixed-address 10.0.10.23;
            hardware ethernet 38:1f:8d:39:8e:06;
        }
        pool {
            range 10.0.10.10 10.0.10.50;
        }
    }
    on commit {
        set shared-networkname = "vlan10";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan20 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.20.1;
    subnet 10.0.20.0 netmask 255.255.255.0 {
        option routers 10.0.20.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.20.10 10.0.20.50;
        }
    }
    on commit {
        set shared-networkname = "vlan20";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan30 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.30.1;
    subnet 10.0.30.0 netmask 255.255.255.0 {
        option routers 10.0.30.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.30.10 10.0.30.50;
        }
    }
    on commit {
        set shared-networkname = "vlan30";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan40 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.40.1;
    subnet 10.0.40.0 netmask 255.255.255.0 {
        option routers 10.0.40.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.40.10 10.0.40.50;
        }
    }
    on commit {
        set shared-networkname = "vlan40";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan50 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.50.1;
    subnet 10.0.50.0 netmask 255.255.255.0 {
        option routers 10.0.50.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host arr {
            fixed-address 10.0.50.16;
            hardware ethernet da:0e:0d:8f:05:3b;
        }
        host caddy {
            fixed-address 10.0.50.3;
            hardware ethernet fe:dc:29:20:67:50;
        }
        host deluge {
            fixed-address 10.0.50.14;
            hardware ethernet d6:7b:d0:98:d6:2b;
        }
        host garage {
            fixed-address 10.0.50.17;
            hardware ethernet f6:3c:40:0d:11:23;
        }
        host gitea {
            fixed-address 10.0.50.20;
            hardware ethernet fe:2f:15:b3:9d:6d;
        }
        host grafana {
            fixed-address 10.0.50.12;
            hardware ethernet 0a:0e:01:16:f9:4c;
        }
        host influxdb {
            fixed-address 10.0.50.8;
            hardware ethernet f6:f7:3b:35:0a:c4;
        }
        host jackett {
            fixed-address 10.0.50.21;
            hardware ethernet 1a:21:50:59:54:ee;
        }
        host jellyfin {
            fixed-address 10.0.50.11;
            hardware ethernet 42:83:00:ba:47:96;
        }
        host lldap {
            fixed-address 10.0.50.18;
            hardware ethernet 92:6c:f5:91:f4:bd;
        }
        host mariadb {
            fixed-address 10.0.50.6;
            hardware ethernet 4a:05:ee:aa:42:50;
        }
        host nas {
            fixed-address 10.0.50.10;
            hardware ethernet ce:35:69:50:4c:95;
        }
        host paperless {
            fixed-address 10.0.50.15;
            hardware ethernet b6:81:3c:6b:36:d1;
        }
        host postgres {
            fixed-address 10.0.50.7;
            hardware ethernet 3a:05:ee:aa:42:50;
        }
        host syslog {
            fixed-address 10.0.50.9;
            hardware ethernet 0e:23:43:84:74:6c;
        }
        host thelounge {
            fixed-address 10.0.50.13;
            hardware ethernet 8a:90:17:27:04:a3;
        }
        host vscode {
            fixed-address 10.0.50.22;
            hardware ethernet 8a:df:13:1b:fd:8e;
        }
        pool {
            range 10.0.50.30 10.0.50.50;
        }
    }
    on commit {
        set shared-networkname = "vlan50";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan60 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.60.1;
    subnet 10.0.60.0 netmask 255.255.255.0 {
        option routers 10.0.60.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.60.10 10.0.60.50;
        }
    }
    on commit {
        set shared-networkname = "vlan60";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan70 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.70.1;
    subnet 10.0.70.0 netmask 255.255.255.0 {
        option routers 10.0.70.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host Clinic {
            fixed-address 10.0.70.13;
            hardware ethernet ec:71:db:5e:1d:6e;
        }
        host EPSON1E715E {
            fixed-address 10.0.70.14;
            hardware ethernet f8:d0:27:1e:71:5e;
        }
        host Outdoors {
            fixed-address 10.0.70.11;
            hardware ethernet ec:71:db:61:0b:71;
        }
        host Road {
            fixed-address 10.0.70.12;
            hardware ethernet ec:71:db:ab:5c:c2;
        }
        host cups {
            fixed-address 10.0.70.7;
            hardware ethernet 3a:c1:ee:aa:42:70;
        }
        host mariadb {
            fixed-address 10.0.70.6;
            hardware ethernet 4a:05:ee:aa:42:70;
        }
        host shinobi {
            fixed-address 10.0.70.10;
            hardware ethernet 6e:75:53:30:80:1e;
        }
        host syslog {
            fixed-address 10.0.70.9;
            hardware ethernet 7e:f9:bf:18:60:36;
        }
        pool {
            range 10.0.70.10 10.0.70.50;
        }
    }
    on commit {
        set shared-networkname = "vlan70";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan99 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.99.1;
    subnet 10.0.99.0 netmask 255.255.255.0 {
        option routers 10.0.99.1;
        default-lease-time 43200;
        max-lease-time 43200;
        host EAP245-60-A4-B7-47-8E-94 {
            fixed-address 10.0.99.2;
            hardware ethernet 60:a4:b7:47:8e:94;
        }
        host EAP660-HD-50-91-E3-C6-18-C6 {
            fixed-address 10.0.99.5;
            hardware ethernet 50:91:e3:c6:18:c6;
        }
        host Openwrt-AP2 {
            fixed-address 10.0.99.4;
            hardware ethernet d8:07:b6:b4:7e:9e;
        }
        host Openwrt-AP4 {
            fixed-address 10.0.99.12;
            hardware ethernet 10:27:F5:7D:AF:A7;
        }
        host TL-SG2210MP {
            fixed-address 10.0.99.7;
            hardware ethernet 00:31:92:76:47:39;
        }
        host TL-SG2210P {
            fixed-address 10.0.99.11;
            hardware ethernet b4:b0:24:98:0c:fa;
        }
        host adguardhome {
            fixed-address 10.0.99.14;
            hardware ethernet 2a:05:ee:40:42:99;
        }
        host omada {
            fixed-address 10.0.99.16;
            hardware ethernet 72:bc:48:bd:7f:cc;
        }
        host pvenas {
            fixed-address 10.0.99.9;
            hardware ethernet a8:a1:59:b7:de:5f;
        }
        host syslog {
            fixed-address 10.0.99.13;
            hardware ethernet 4a:9e:f4:1f:cd:de;
        }
        pool {
            range 10.0.99.20 10.0.99.50;
        }
    }
    on commit {
        set shared-networkname = "vlan99";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan150 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.150.1;
    subnet 10.0.150.0 netmask 255.255.255.0 {
        option routers 10.0.150.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.150.10 10.0.150.50;
        }
    }
    on commit {
        set shared-networkname = "vlan150";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}

shared-network vlan160 {
    authoritative;
    option domain-name-servers 10.0.99.14;
    option domain-name "home.arpa";
    option domain-search "home.arpa";
    option ntp-servers 10.0.160.1;
    subnet 10.0.160.0 netmask 255.255.255.0 {
        option routers 10.0.160.1;
        default-lease-time 43200;
        max-lease-time 43200;
        pool {
            range 10.0.160.10 10.0.160.50;
        }
    }
    on commit {
        set shared-networkname = "vlan160";
        set ClientIp = binary-to-ascii(10, 8, ".", leased-address);
        set ClientMac = binary-to-ascii(16, 8, ":", substring(hardware, 1, 6));
        set ClientName = pick-first-value(host-decl-name, option fqdn.hostname, option host-name, "empty_hostname");
        if not (ClientName = "empty_hostname") {
            set ClientDomain = pick-first-value(config-option domain-name, "..YYZ!");
            execute("/usr/libexec/vyos/system/on-dhcp-event.sh", "commit", ClientName, ClientIp, ClientMac, ClientDomain);
        } else {
            log(concat("Hostname is not defined for client with IP: ", ClientIP, " MAC: ", ClientMac));
        }
    }
}


use-host-decl-names on; was added separately so that’s why it’s repeated in the config.

In dhcp_server.py, It adds use-host-decl-names on; if host-decl-name was set and then it checks for the value of host-decl-name at 2 other places. at one of these places, the check fails and it adds shared network name as prefix.

Manually setting use-host-decl-names on; will not fix the problem because it’s still looking at the host-decl-name parameter in vyos config.

so now I have to figure out why vyos won’t let me set this parameter in vyos config.

dhcpd throws an error like

WARNING: Host declarations are global.  They are not limited to the scope you declared them in.
dhcpd.tmp.conf line 322: host mariadb: already exists
        }
         ^
dhcpd.tmp.conf line 330: host syslog: already exists
        }
         ^
dhcpd.tmp.conf line 398: host syslog: already exists
        }
         ^
Configuration file errors encountered -- exiting

I think if I correct these conflicts, It should work!

Vyos starts dhcpd with -q so it was not logging any of this to console. Adjusting log levels some where probably fixes that, I don’t know where is that setting

YAY!

10.0.10.34      emerald.home.arpa
# dhcp-server-10.0.70.7
10.0.70.7       cups.home.arpa
# dhcp-server-10.0.99.16
10.0.99.16      omada.home.arpa
# dhcp-server-10.0.50.9
10.0.50.9       syslog.home.arpa
# dhcp-server-10.0.20.10
10.0.20.10      21051182G.home.arpa

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.