我需要为以下场景创建 iptables 规则:
A。目标端口是1234.A(8.2.3.4)将收到的UDP数据重定向到主机B1(7.2.3.1)、B2(22.93.12.3)、... Bn(12.42.1.3);IP 地址仅供参考。B1, B2, ...Bn必须接收所有包。因此,主机A必须复制包。B1, B2, ... Bn)和源IP(主机A)AB1,B2...BnB1, B2, ...Bn不必能够回复我尝试用PREROUTING/解决这个问题mangle:
HOST_A=8.2.3.4
HOST_B1=7.2.3.1
HOST_B2=22.93.12.3
...
HOST_BN=12.42.1.3
iptables -F -t mangle
iptables -t mangle -A PREROUTING -d $HOST_A …Run Code Online (Sandbox Code Playgroud) 我正在尝试根据原始进程的 uid 来路由数据包。
我知道传出数据包不会命中 PREROUTING。在 iptables 中有一个 MANGLE 表,您可以将这些规则放置在 OUTPUT 链中。nftables 没有 MANGLE 钩子之类的东西。只有 OUTPUT 挂钩。
这是 nftables 的限制吗?在路由决策之前,无法标记源自主机的传出数据包?
nftables v0.7 (Scrooge McDuck)
Linux 4.14.5-1-ARCH #1 SMP PREEMPT Sun Dec 10 14:50:30 UTC 2017 x86_64 GNU/Linux
Run Code Online (Sandbox Code Playgroud) 在 nftables 中,我可以使用以下规则来匹配 IPv4 UDP DNS 数据包。
ip protocol udp udp dport 53 accept
Run Code Online (Sandbox Code Playgroud)
但 IPv6 变体
ip6 protocol udp udp dport 53 accept
Run Code Online (Sandbox Code Playgroud)
失败,nftables 说
v0001.nft:39:5-12: Error: syntax error, unexpected protocol
ip6 protocol udp udp dport 53 accept
^^^^^^^^
Run Code Online (Sandbox Code Playgroud)
例如:
#!/usr/sbin/nft -f
add table ip filter_4
add chain ip filter_4 input {
type filter hook input priority filter; policy drop;
}
add chain ip filter_4 new_in_4 {
comment "New input IPv4 traffic"
}
# Note it's goto not jump! (thus no way out of new_in_4 chain)
add rule ip filter_4 input ct state new goto new_in_4
# Is this block drop or accept rule?
add rule ip filter_4 new_in_4 log prefix "some comment: "
Run Code Online (Sandbox Code Playgroud)
该规则没有明确accept或drop判决,那么哪个是默认的?