Register DHCP hostnames with DNS forwarder

How can I make it so that hostnames supplied by machines using the DHCP server are registered with the DNS forwarder? So that they can be resolved by other systems on the LAN.

2 Likes

This is no supported at this time

Thanks for the prompt reply!

Is it by now or what could be done to achieve this?

Could VyOS talk to an external DNS server and update it with dhcp leases/mappings?

Hello,
i think in current rolling it’s supported but may require testing

Cool! I’m on rolling. How could I test it?

nope, my bad, still not possible
but now i think we can implement this
let me investigate on that

you can try rolling from here https://downloads.vyos.io/?dir=rolling/current/amd64

1 Like

See
on-dhcp-event.sh - https://github.com/vyos/vyatta-cfg-dhcp-server/blob/ba5569c069bd5b0e67a23c6bdc363916beaeefe3/scripts/system/on-dhcp-event.sh
looks like it already adds records to hosts file
and dns forwarder should serve them just fine

I think what is missing is way to configure domain

Domain name can be set with

set system domain-name xyz

It could/should take it from there as a start?

Hmm it doesn’t add records to /etc/hosts here on VyOS 1.2.0-rolling+201807050337

But it does seem to expose /etc/hosts records via DNS to clients resulting in

ping vyos.domain

from another host, pinging 127.0.0.1 which makes no sense :wink:

Indeed it works! :tada::confetti_ball: :smiley:

It has to be enabled manually though, even if cli completion claims this is the default setting?
“enable Enable updating /etc/host file (default)”

set service dhcp-server hostfile-update enable

Then /etc/hosts gets updated and distributed via dns so all machines have it.

The domain though is not being added only the hostname, as you suspected.

This doesn’t seem to work for me on VyOS 1.3-rolling-202009070118 .

I’ve set

set service dhcp-server hostfile-update

Then

> vyos@vyos:~$ cat /etc/hosts
> ### Autogenerated by VyOS ###
> ### Do not edit, your changes will get overwritten ###
> 
> # Local host
> 127.0.0.1       localhost
> 127.0.1.1       vyos.vymicro.xxx.xyz vyos
> 
> # The following lines are desirable for IPv6 capable hosts
> ::1             localhost ip6-localhost ip6-loopback
> fe00::0         ip6-localnet
> ff00::0         ip6-mcastprefix
> ff02::1         ip6-allnodes
> ff02::2         ip6-allrouters

I assume I should have a line like:

# From DHCP and "system static host-mapping"
vyos@vyos# show service dhcp-server
 hostfile-update
 shared-network-name management_vyos {
     authoritative
     subnet 192.168.128.0/24 {
         default-router 192.168.128.128
         dns-server 192.168.60.60
         domain-name vymicro.xxxx.xyz
         lease 86400
         range 0 {
             start 192.168.128.10
             stop 192.168.128.20
         }
         static-mapping vm-ansible {
             ip-address 192.168.128.73
             mac-address 0a:d4:d5:5b:2d:94