AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题 / 786136
Accepted
dotslash
dotslash
Asked: 2016-06-25 10:58:03 +0800 CST2016-06-25 10:58:03 +0800 CST 2016-06-25 10:58:03 +0800 CST

如何动态查看 dnsmasq 客户端 MAC 地址?

  • 772

如果我已经知道客户端 IP,我知道有/var/log/dnsmasq.log,并且它包含日志,例如

6 月 13 日 12:22:42 dnsmasq-dhcp[499]: DHCPACK(wlan0) 172.24.1.110 34:12:98:11:80:bd 个-iPad
6 月 13 日 13:19:44 dnsmasq-dhcp[499]: DHCPDISCOVER (wlan0) d4:97:32:61:4f:73
Jun 13 13:19:44 dnsmasq-dhcp[499]: DHCPOFFER(wlan0) 172.24.1.82 d4:97:0b:61:4f:23
Jun 13 13: 19:44 dnsmasq-dhcp[499]: DHCPREQUEST(wlan0) 172.24.1.82 d4:97:9f:61:4f:73
Jun 13 13:19:44 dnsmasq-dhcp[499]: DHCPACK(wlan0) 172.24.1.82 d4 :97:0b:23:4f:73 android-ef9f423f7ecaca3c

在路由器中

这样,我们每次都可以解析日志,看到最新的MAC地址。

但是不用每次都解析这么长的大文件,我们能知道客户端mac是什么吗?它拖累CPU。

谢谢!


更新

我找到了另一个包含它的地方

cat /var/lib/misc/dnsmasq.leases

仍然是一个文件。还是我每次都必须解析文件?

linux logging mac-address dnsmasq hostapd
  • 1 1 个回答
  • 5388 Views

1 个回答

  • Voted
  1. Best Answer
    TJM
    2016-06-25T11:16:26+08:002016-06-25T11:16:26+08:00

    在 dnsmasq 的手册页中有一个选项说

    -l, --dhcp-leasefile=<path>
        Use the specified file to store DHCP lease information.
    

    因此,您可以使用文件来记录它。文件的格式是:

     946689575 00:00:00:00:00:05 192.168.1.155 wdt 01:00:00:00:00:00:05
     946689522 00:00:00:00:00:04 192.168.1.237 * 01:00:00:00:00:00:04
     946689351 00:0f:b0:3a:b5:0b 192.168.1.208 colinux *
     946689493 02:0f:b0:3a:b5:0b 192.168.1.199 * 01:02:0f:b0:3a:b5:0b
    

    每行的字段:

     1) Time of lease expiry, in epoch time (seconds since 1970). BTW you
     seem to be living in the past: most of us are well past 1000000000
     seconds by now :-) . There are compile time options in dnsmasq which
     convert this field to be remaining lease time (in seconds) or, in the
     most recent releases, total lease renewal time.
    
     2) MAC address.
    
     3) IP address.
    
     4) Computer name, if known. This is always unqualified (no domain part)
    
     5) Client-ID, if known. The client-ID is used as the computer's
     unique-ID in preference to the MAC address, if it's available. Some DHCP
     clients provide it, and some don't. The ones that do normally derive it
     from the MAC address unless explicity configured, but it could be
     something like a serial number, which would protect a computer from
     losing its identify if the network interface were replaced.
    

    行的顺序没有意义,并且会随着时间而改变。

    • 1

相关问题

  • 多操作系统环境的首选电子邮件客户端

  • 你最喜欢的 Linux 发行版是什么?[关闭]

  • 更改 PHP 的默认配置设置?

  • 保护新的 Ubuntu 服务器 [关闭]

  • (软)Ubuntu 7.10 上的 RAID 6,我应该迁移到 8.10 吗?

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve