1

I'm aware that you can assign static DNS entry names by doing the following in dnsmasq.conf:

address=/wiki.leerdomain.lan/192.168.1.200
ptr-record=wiki.leerdomain.lan/192.168.1.200

and then assigning a static ip address using the mac address of the machine in question using DHCP (see the UCI configuration from OpenWRT below):

config host
    option name 'wiki.leerdomain.lan'
    option mac 'xx:xx:xx:xx:xx:xx'
    option ip '192.168.1.200'

However, how then can I set the hostname of the Linux machine with option DHCP option 12? (or am I already doing that with the second snippet?)

I'm expecting the machine in question to be able to run the command hostname and receive the hostname assigned by option 12.

leeand00
  • 4,807
  • 13
  • 64
  • 106
  • 1
    To make it clear: You wish to assign the hostname of the client based on the fqdn you assigned in the dnsmasq server? – Leo Jul 16 '18 at 07:40

2 Answers2

2

In Dnsmasq, if you can edit the config file directly, you can specify a hostname for dhcp clients as follows:

dhcp-host=f8:da:0c:0a:af:c9,192.168.1.222,SpecialMachine,30d

This will assign client with the MAC address f8:da:0c:0a:af:c9 the IP 192.168.1.222, the hostname "SpecialMachine" and a DHCP lease time of 30 days.

[Apologies. In lieu of deleting this post, I figured, best to explain that in my case, what I wanted to accomplish was ensure that the device hostname showed up in my router as I wanted it. I did not verify that the device actually changed it's hostname].

nucc1
  • 136
  • 2
1

If I undestood the question correctly, and you wish to assign the hostnames from the dnsmasq DHCP Server to the clients, on most Linux distributions it is the default for dhclient to send the hostname.

You can confirm if your clients are sending their hostname to the DHCP server in dhclient.conf, with the send host-name option:

$ cat /etc/dhcp/dhclient.conf | grep send
send host-name = gethostname();

You might get what you want by commenting that line and making sure you have assigned hostnames for every host in dnsmasq so the clients get one. You might have to load them in the /etc/hosts or equivalent source for your server.

Leo
  • 1,833
  • 8
  • 17