Сохранять вывод arp в терминале в текстовый файл каждую минуту с помощью crontab

Вы правы. В вашей настройке у вас есть набор «точка-точка» VPN между вашими клиентами и сервером. Связь между клиентами должна осуществляться на сервере.

Действительно, по умолчанию клиенты не могут видеть друг друга, если сервер не разрешает это. Из справочной страницы:

   --client-to-client
          Because the OpenVPN server mode handles multiple clients through
          a  single tun or tap interface, it is effectively a router.  The
          --client-to-client  flag  tells  OpenVPN  to  internally   route
          client-to-client  traffic  rather than pushing all client-origi-
          nating traffic to the TUN/TAP interface.

          When this option is used,  each  client  will  "see"  the  other
          clients  which  are currently connected.  Otherwise, each client
          will only see the server.  Don't use this option if you want  to
          firewall tunnel traffic using custom, per-client rules.
2
21.07.2017, 22:06
2 ответа

Проблема, по-видимому, в том, что crontab не знает PATH, где находится команда arp.

Я бы использовал:

* * * * * /usr/sbin/arp -n >> results.txt

Тем не менее, я бы использовал arpwatch для мониторинга изменений ARP. Он работает как демон и регистрирует изменения MAC-адреса в файле с течением времени вместе с эпохой изменения. Он также может отправлять сообщения в системный журнал и электронную почту.

От человек арпвотч

Arpwatch keeps track for ethernet/ip address pairings. It syslogs activity and reports certain changes via email. Arpwatch uses pcap(3) to listen for arp packets on a local ethernet interface.

Report Messages

Here's a quick list of the report messages generated by arpwatch(1) (and arpsnmp(1)):

new activity This ethernet/ip address pair has been used for the first time six months or more.

new station The ethernet address has not been seen before.

flip flop The ethernet address has changed from the most recently seen address to the second most recently seen address. (If either the old or new ethernet address is a DECnet address and it is less than 24 hours, the email version of the report is suppressed.)

changed ethernet address The host switched to a new ethernet address.

Syslog Messages

Here are some of the syslog messages; note that messages that are reported are also sysloged.

ethernet broadcast The mac ethernet address of the host is a broadcast address.

ip broadcast The ip address of the host is a broadcast address.

bogon The source ip address is not local to the local subnet.

ethernet broadcast The source mac or arp ethernet address was all ones or all zeros.

ethernet mismatch The source mac ethernet address didn't match the address inside the arp packet.

reused old ethernet address The ethernet address has changed from the most recently seen address to the third (or greater) least recently seen address. (This is similar to a flip flop.)

suppressed DECnet flip flop A "flip flop" report was suppressed because one of the two addresses was a DECnet address.

Files

/var/lib/arpwatch - default directory

arp.dat - ethernet/ip address database

ethercodes.dat - vendor ethernet block list

5
27.01.2020, 21:50

Предложения о arpwatchхороши, но если вы не хотите идти по этому пути:

Я предлагаю создать файл, содержащий:

#!/bin/sh
arp -n >> results.txt  

(обратите внимание на >>, иначе вы получите сообщение об ошибке после первого запуска ). Убедитесь, что он исполняемый с помощью:

chmod 755 file  

, а затем запустите его из crontab.

1
27.01.2020, 21:50

Теги

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