DHCP clients not getting a hostname reliably from vyos DHCP-server

Hey all :slight_smile:

I want to preface this with the information that I am a complete vyos beginner (although not new to networking, sysadmin …) so I might as well be missing something very obvious in the configuration.

I have a pretty straight forward setup, vyos as my router/dhcp server/dns resolver for a set of servers in my homelab (all virtualized).

On the WAN side it’s pretty straight forward, my upstream router hands vyos a static IP based on its MAC address and internet access.
On the LAN side I want vyos to:

  • hand out predefined IPs to clients based on their MAC address :white_check_mark:
  • inform each DHCP client what its hostname is (this is where I’m seeing not so reliable results)
  • Resolve A and PTR queries for the clients’ FQDN :white_check_mark:

My problem is that while sometimes my clients are getting their hostname from the vyos dhcp server it’s not always (even for the same client across reboots) and the hostname that I’ve observed my clients getting is either their desired hostname, their FQDN or localhost.

Things that work well:

  • reliably assign IP to clients based on their MAC address
  • Name resolution (i.e. dig master0 @10.0.0.1 and dig -x 10.0.0.3 @10.0.0.1 reply with the expected A and PTR records, same works from clients of vyos)

Things that don’t really work:

  • Reliably set hostname (oscillates between hostname, fqdn and localhost)
  • show dhcp server statistics and show dhcp server leases state all always come back empty, regardless of how many clients are connected and got their IP through DHCP (but always statically leased). Minor observation, doesn’t really affect operations.

My config (redacting / minifying for space and privacy) is :

interfaces {
    ethernet eth0 {
        address dhcp
        description WAN
        offload { ... }
    }
    ethernet eth1 {
        address 10.0.0.1/24
        description LAN
        offload { ... }
    }
    loopback lo {}
}
nat {
    source {
        rule 100 {
            outbound-interface eth0
            source {
                address 10.0.0.0/24
            }
            translation {
                address masquerade
            }
        }
    }
}
service {
    dhcp-server {
        shared-network-name LAN {
            subnet 10.0.0.0/24 {
                default-router 10.0.0.1
                lease 86400
                name-server 10.0.0.1
                static-mapping bootstrap {
                    ip-address 10.0.0.8
                    mac-address <REDACTED>
                }
                static-mapping lb {
                    ip-address 10.0.0.2
                    mac-address <REDACTED>
                }
                static-mapping master0 {
                    ip-address 10.0.0.3
                    mac-address <REDACTED>
                }
                static-mapping master1 {
                    ip-address 10.0.0.4
                    mac-address <REDACTED>
                }
                static-mapping master2 {
                    ip-address 10.0.0.5
                    mac-address <REDACTED>
                }
                static-mapping worker0 {
                    ip-address 10.0.0.6
                    mac-address <REDACTED>
                }
                static-mapping worker1 {
                    ip-address 10.0.0.7
                    mac-address <REDACTED>
                }
            }
        }
    }
    dns {
        forwarding {
            allow-from 10.0.0.0/24
            cache-size 0
            listen-address 10.0.0.1
        }
    }
    ssh { ... }
}
system {
    ...
    host-name router
    ipv6 {
        disable-forwarding
    }
    login { ... }
    name-server 192.168.50.1
    name-server eth0
    ntp { ... }
    static-host-mapping {
        host-name bootstrap {
            alias bootstrap.sub.domain.com
            inet 10.0.0.8
        }
        host-name lb {
            alias api-int.sub.domain.com
            inet 10.0.0.2
        }
        host-name master0 {
            alias master0.sub.domain.com
            inet 10.0.0.3
        }
        host-name master1 {
            alias master1.sub.domain.com
            inet 10.0.0.4
        }
        host-name master2 {
            alias master2.sub.domain.com
            inet 10.0.0.5
        }
        host-name worker0 {
            alias worker0.sub.domain.com
            inet 10.0.0.6
        }
        host-name worker1 {
            alias worker1.sub.domain.com
            inet 10.0.0.7
        }
    }
    ...
}

Most of the times, if a DHCP option doesn’t seem to work (even invisible in sniffer), check to see if the client requests this option.

1 Like

Thank you :slight_smile:

Somewhat of a Layer 8 problem … my clients weren’t getting their (unreliable) hostnames through DHCP (that’s for me to troubleshoot but I suspect isn’t VyOS related) but rather getting their hostname through a PTR lookup of their IP. With the above config this will return both the hostname and FQDN. For the localhost cases I suspect that IPv6 is in play, which I assumed would be disabled-by-default but it seems to not be the case.