标签: nftables

iptables / nftables:将UDP数据转发到多个目标

我需要为以下场景创建 iptables 规则:

  • 不同的主机向主机发送UDP数据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必须复制包。
  • 转发的包必须有正确的目标IP(B1, B2, ... Bn)和源IP(主机A
  • 我无法更改向主机发送数据的初始主机上的任何内容A
  • 我无法更改目标主机上的任何内容B1B2...Bn
  • 主持人B1, 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)

networking linux iptables forwarding nftables

5
推荐指数
1
解决办法
3862
查看次数

使用 nftables 根据 UID 做出路由决策

我正在尝试根据原始进程的 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)

networking linux firewall nftables

3
推荐指数
1
解决办法
8416
查看次数

使用 nftables 匹配 IPv6 协议

在 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)

根据文档中的示例, ip6 没有协议字段,但是如何使用 nftables 基于协议匹配这些数据包?为什么那里没有协议?

networking firewall ipv6 nftables

3
推荐指数
1
解决办法
525
查看次数

nftables 规则的默认判决是什么?

例如:

#!/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)

该规则没有明确acceptdrop判决,那么哪个是默认的?

linux nftables

3
推荐指数
1
解决办法
330
查看次数

标签 统计

nftables ×4

linux ×3

networking ×3

firewall ×2

forwarding ×1

iptables ×1

ipv6 ×1