在哪查看 dhcp 租约信息 ? 如何让 dnsmasq dhcp 在 192.168.0.1 而非 0:0:0:0 ?

2017-08-25 07:23:10 +08:00
 station
虚拟机客户端 dhcp,没 google 到这方面的信息

主机在搭建 nas+软路由: 调试配置中 dnsmasq 是在 0:0:0:0 上进行 dhcp 而非 192.168.0.1 上,google 没有什么收获...
5750 次点击
所在节点    Linux
11 条回复
exkernel
2017-08-25 07:49:56 +08:00
station
2017-08-25 08:43:07 +08:00
@exkernel 我想说结果一样, dnsmasq dhcp server 还是在 0:0:0:0 上监听

狂且我本就是如此写的 conf 文件
xfspace
2017-08-25 08:59:11 +08:00
# If you want dnsmasq to listen for DHCP and DNS requests only on
# specified interfaces (and the loopback) give the name of the
# interface (eg eth0) here.
# Repeat the line for more than one interface.
#interface=
# Or you can specify which interface _not_ to listen on
#except-interface=
# Or which to listen on by address (remember to include 127.0.0.1 if
# you use this.)
#listen-address=
# If you want dnsmasq to provide only DNS service on an interface,
# configure it as shown above, and then use the following line to
# disable DHCP and TFTP on it.
#no-dhcp-interface=

# On systems which support it, dnsmasq binds the wildcard address,
# even when it is listening on only some interfaces. It then discards
# requests that it shouldn't reply to. This has the advantage of
# working even when interfaces come and go and change address. If you
# want dnsmasq to really bind only the interfaces it is listening on,
# uncomment this option. About the only time you may need this is when
# running another nameserver on the same machine.
#bind-interfaces


都试试?
predator
2017-08-25 09:02:31 +08:00
bind-interfaces
需要写多这一条

dhcp 租约需要加一句
log-dhcp
然后在输出日志上可以 tail 到详细的租约信息(最好注释掉 log-queries )
station
2017-08-25 09:07:14 +08:00
@xfspace 就是如此才是最恶心的
station
2017-08-25 09:11:05 +08:00
@predator 看我刚回复的

客户机是台虚拟机,配合家庭服务器(nas+软路由)在调试配置
so 我需要查看 dhcp 信息( 租约和续租时间 )
predator
2017-08-25 09:21:32 +08:00
就两条配置就够了啊

log-dhcp
log-facility=/var/log/dnsmasq.log

然后再上面指定的日志文件里面就可以拿到详尽的 dhcp 信息:

Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 available DHCP range: 192.168.1.201 -- 192.168.1.232
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 client provides name: iPhone
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 DHCPREQUEST(eth0) 192.168.1.227 44:00:10:a3:87:da
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 tags: eth0
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 DHCPACK(eth0) 192.168.1.227 44:00:10:a3:87:da iPhone
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 requested options: 1:netmask, 121:classless-static-route, 3:router,
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 requested options: 6:dns-server, 15:domain-name, 119:domain-search,
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 requested options: 252
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 next server: 192.168.1.1
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 1 option: 53 message-type 5
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 54 server-identifier 192.168.1.1
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 51 lease-time 2d
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 58 T1 1d
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 59 T2 1d18h
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 1 netmask 255.255.255.0
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 28 broadcast 192.168.1.255
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 6 dns-server 192.168.1.1
Aug 25 09:16:51 dnsmasq-dhcp[6353]: 1819931555 sent size: 4 option: 3 router 192.168.1.1
predator
2017-08-25 09:25:30 +08:00
还有一个你可能用得上的是:

dhcp-leasefile=/var/log/dhcp.leases

这里可以记录到全部客户端的租约信息
jasontse
2017-08-25 09:25:41 +08:00
DHCP 要接收广播消息,怎么可以限定地址。
lazycat
2017-08-25 09:33:36 +08:00
DHCP 获取到地址之前客户端本身是没有 IP 地址的。。。先不说能不能限制如果你真做到了把 dnsmasq 限制监听 192.168.0.1 这个段后果就是新设备全部无法获取 IP 地址上不了网除非你手动分配一个这个网段的 IP,不过手动分配的话还要 DHCP 有什么用呢。。。
lybtongji
2017-08-25 15:49:59 +08:00
不如 mac 绑定吧

这是一个专为移动设备优化的页面(即为了让你能够在 Google 搜索结果里秒开这个页面),如果你希望参与 V2EX 社区的讨论,你可以继续到 V2EX 上打开本讨论主题的完整版本。

https://www.v2ex.com/t/385605

V2EX 是创意工作者们的社区,是一个分享自己正在做的有趣事物、交流想法,可以遇见新朋友甚至新机会的地方。

V2EX is a community of developers, designers and creative people.

© 2021 V2EX