V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
station
V2EX  ›  Linux

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

  •  
  •   station · Aug 25, 2017 · 6442 views
    This topic created in 3178 days ago, the information mentioned may be changed or developed.
    虚拟机客户端 dhcp,没 google 到这方面的信息

    主机在搭建 nas+软路由: 调试配置中 dnsmasq 是在 0:0:0:0 上进行 dhcp 而非 192.168.0.1 上,google 没有什么收获...
    11 replies    2017-08-25 15:49:59 +08:00
    station
        2
    station  
    OP
       Aug 25, 2017
    @exkernel 我想说结果一样, dnsmasq dhcp server 还是在 0:0:0:0 上监听

    狂且我本就是如此写的 conf 文件
    xfspace
        3
    xfspace  
       Aug 25, 2017 via Android
    # 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
        4
    predator  
       Aug 25, 2017
    bind-interfaces
    需要写多这一条

    dhcp 租约需要加一句
    log-dhcp
    然后在输出日志上可以 tail 到详细的租约信息(最好注释掉 log-queries )
    station
        5
    station  
    OP
       Aug 25, 2017
    @xfspace 就是如此才是最恶心的
    station
        6
    station  
    OP
       Aug 25, 2017
    @predator 看我刚回复的

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

    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
        8
    predator  
       Aug 25, 2017
    还有一个你可能用得上的是:

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

    这里可以记录到全部客户端的租约信息
    jasontse
        9
    jasontse  
       Aug 25, 2017 via Android
    DHCP 要接收广播消息,怎么可以限定地址。
    lazycat
        10
    lazycat  
       Aug 25, 2017
    DHCP 获取到地址之前客户端本身是没有 IP 地址的。。。先不说能不能限制如果你真做到了把 dnsmasq 限制监听 192.168.0.1 这个段后果就是新设备全部无法获取 IP 地址上不了网除非你手动分配一个这个网段的 IP,不过手动分配的话还要 DHCP 有什么用呢。。。
    lybtongji
        11
    lybtongji  
       Aug 25, 2017
    不如 mac 绑定吧
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2969 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 52ms · UTC 15:27 · PVG 23:27 · LAX 08:27 · JFK 11:27
    ♥ Do have faith in what you're doing.