如何使用 iptables 标记出站 FTP 流量?

如何使用 iptables 标记出站 FTP 流量?

我的 Debian 系统中有一个名为“testuser”的用户,我想标记来自 testuser 帐户的 FTP 流量

我怎样才能做到这一点?

我使用以下命令标记“testuser”的所有传出流量

iptables -t mangle -N HTB_OUT
iptables -t mangle -I POSTROUTING -j HTB_OUT
iptables -t mangle -A HTB_OUT -m owner --uid-owner testuser -j MARK --set-mark 10

如何为“testuser”设置两个标记?一个仅用于 FTP 流量,另一个用于所有其他流量?

答案1

添加 --dport (--destination-port) 选项。您至少需要其中两个 - 20:21 用于 FTP 流量,!20:21 用于非 FTP。

相关内容