Как динамически просматривать MAC-адреса клиента dnsmasq?

Если я уже знал IP клиента, я знаю там /var/log/dnsmasq.log , и он содержит журналы, такие как

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

В маршрутизаторе

Таким образом, мы можем проанализировать журнал каждый раз, чтобы увидеть последний MAC-адрес.

Но можем ли мы узнать, что такое клиент Mac, не анализируя каждый раз этот длинный большой файл. Это снижает нагрузку на ЦП.

Спасибо!


обновлено

Я нашел другое место, содержащее это

cat /var/lib/misc/dnsmasq.leases[12194estiveТем не менее, это файл. Или мне нужно каждый раз разбирать файл?

0
задан 24 June 2016 в 22:10
1 ответ

На странице руководства 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
ответ дан 4 December 2019 в 16:34

Теги

Похожие вопросы