我有一个配置,它将所有标记的数据包重定向到侦听端口 1082 的代理服务器,它可以工作:
ipset create unblock hash:net -exist
iptables -I PREROUTING -w -t nat -i br0 -p tcp -m set --match-set unblock dst -j REDIRECT --to-port 1082
iptables -I PREROUTING -w -t nat -i br0 -p udp -m set --match-set unblock dst -j REDIRECT --to-port 1082
我还有一个 Wireguard 接口(ngw0),端口 48950 上的 IP 地址为 172.16.0.2。我想做的是将这些数据包重定向到wireguard 接口。尝试过灵魂:
ipset create unblock hash:net -exist
iptables -I PREROUTING -w -t nat -i br0 -p tcp -m set --match-set unblock dst -j DNAT --to-destination 172.16.0.2:48950
iptables -I PREROUTING -w -t nat -i br0 -p udp -m set --match-set unblock dst -j DNAT --to-destination 172.16.0.2:48950
和
ipset create unblock hash:net -exist
iptables -I PREROUTING -w -t nat -i br0 -p tcp -m set --match-set unblock dst -j MASQUERADE -o nwg0
iptables -I PREROUTING -w -t nat -i br0 -p udp -m set --match-set unblock dst -j MASQUERADE -o nwg0
这些都不起作用。如何将流量重定向到 Wireguard?
更新:
ip addr show br0
24: br0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue
link/ether xx:xx:xx:xx:xx:xx brd ff:ff:ff:ff:ff:ff
inet 192.168.0.1/24 brd 192.168.0.255 scope global br0
valid_lft forever preferred_lft forever
ip addr show nwg0
27: nwg0: <POINTOPOINT,NOARP,UP,LOWER_UP> mtu 1324 qdisc noqueue qlen 50
link/[65534]
inet 172.16.0.2/32 scope global nwg0
valid_lft forever preferred_lft forever
~ # netstat -an | grep 48950
udp 0 0 0.0.0.0:48950 0.0.0.0:*
udp 0 0 :::48950 :::*
~ # netstat -an | grep 1082
tcp 0 0 :::1082 :::* LISTEN
tcp 0 0 ::ffff:192.168.0.1:1082 ::ffff:192.168.0.130:56540 TIME_WAIT