大网数据广告活动
服务器运维问答

Assigning a hostname of the fqdn assigned to a dhcp client with dnsmasq?

· 52CE 我爱测

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…

问题原文

原帖链接 · leeand00 · CC BY-SA 4.0

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.

已采纳解答

原帖链接 · nucc1 · CC BY-SA 4.0

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].

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-10-31)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。