【问题标题】:MAC Address Blocking/Filtering on Wifi Access Point using command line terminal使用命令行终端在 Wifi 接入点上进行 MAC 地址阻止/过滤
【发布时间】:2020-02-21 19:44:11
【问题描述】:
我可以通过在 Jatson Nano 中充当接入点的 wifi 卡在 Raspberry Pi 中获得 Wifi 连接。
但现在我想继续研究连接到 Jatson Nano AP 并启动的设备,而不是 Raspberry Pi。如果我假设我知道 Pi 的 MAC 地址,是否可以启动任何与该 MAC 地址不匹配的设备?
注意:这个 AP 是 wifi 卡而不是路由器,所以没有设置面板来过滤 MAC 地址,只能通过 ssh 或一些 bash/python 脚本使用终端命令来完成
是否可以使用终端阻止/过滤特定的 MAC 地址?
【问题讨论】:
标签:
terminal
raspberry-pi
wifi
mac-address
access-point
【解决方案1】:
您可以尝试使用iptables 按MAC 地址过滤。查看this answer。
# Create the DHCP_clients chain in the 'raw' table
iptables -t raw -N DHCP_clients
# Incoming DHCP, pass to chain processing DHCP
iptables -t raw -A PREROUTING -p udp --dport 67 -j DHCP_clients
# Allowed DHCP clients
iptables -t raw -A DHCP_clients -m mac --mac-source <ALLOWED MAC> -j ACCEPT
# Deny other clients not listed above
iptables -t raw -A DHCP_clients -j DROP
raw:此表主要用于结合 NOTRACK 目标配置连接跟踪的豁免。它在具有更高优先级的 netfilter 挂钩上注册,因此在 ip_conntrack 或任何其他 IP 表之前调用。它提供以下内置链: PREROUTING(用于通过任何网络接口到达的数据包) OUTPUT(用于由本地进程生成的数据包)
-t, --table table
This option specifies the packet matching table which the command should operate on.
-N, --new-chain chain
Create a new user-defined chain by the given name. There must be no target of that name already.
- 原始表提供
PREROUTING(对于通过任何网络接口到达的数据包),-A 将规则附加到您的链中。
- DHCP 使用端口 67 和 68 以及 UDP 协议。您可以通过阻止这些端口上的通信来阻止 DHCP 请求。
-A, --append chain rule-specification
Append one or more rules to the end of the selected chain.
- 然后您有规则只接受您想要的 MAC 地址并丢弃所有其他地址。
iptables manual