![基于Linux的路由器iptable规则将所有流量导向特定MAC](https://linux22.com/image/599582/%E5%9F%BA%E4%BA%8ELinux%E7%9A%84%E8%B7%AF%E7%94%B1%E5%99%A8iptable%E8%A7%84%E5%88%99%E5%B0%86%E6%89%80%E6%9C%89%E6%B5%81%E9%87%8F%E5%AF%BC%E5%90%91%E7%89%B9%E5%AE%9AMAC.png)
我有一个基于 Linux 的路由器。我正在尝试创建一个 iptable 规则,以使用其 mac 地址重定向特定客户端的流量。这是我现在的规则(不起作用):
iptables -t nat -A prerouting_lan -m mac --mac-source $mac -i br-lan -p tcp --dport 80 -j DNAT --to $ipaddr
我做错了什么?任何建议我都会很感激。
电动汽车
答案1
尝试将 DNAT 字段中的“--to”更改为“--to-destination”。来自“man iptables”:
DNAT
This target is only valid in the nat table, in the PREROUTING and OUTPUT chains, and user-defined chains which are only called
from those chains. It specifies that the destination address of the packet should be modified (and all future packets in this
connection will also be mangled), and rules should cease being examined. It takes one type of option:
--to-destination [ipaddr][-ipaddr][:port[-port]]