Iptables: 如何只解决一个 ip 通过某个港口?

我怎么能在我的服务器上 ubuntu 在 Iptables 仅在特定端口上只允许一个IP地址?

已邀请:

二哥

赞同来自:

一个衬里:

iptables -I INPUT \! --src 1.2.3.4 -m tcp -p tcp --dport 777 -j DROP  # if it's not 1.2.3.4, drop it

更优雅的解决方案:

iptables -N xxx # create a new chain
iptables -A xxx --src 1.2.3.4 -j ACCEPT # allow 1.2.3.4
iptables -A xxx --src 1.2.3.5 -j ACCEPT # allow 1.2.3.5
iptables -A xxx --src 1.2.3.6 -j ACCEPT # allow 1.2.3.6
iptables -A xxx -j DROP # drop everyone else
iptables -I INPUT -m tcp -p tcp --dport 777 -j xxx # use chain xxx for packets coming to TCP port 777

裸奔

赞同来自:

我用 shorewall 配置IP表。 例如,使用规则从一个主机接收到端口 123.

拿网络: 192.0.2.1 $ FW tcp 1234

郭文康

赞同来自:

这是我的一个系统的一个例子。 CentOS (地址已经讨论了):

-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp -s 1.2.3.4 -d 5.6.7.8 --dport 22 -j ACCEPT

要回复问题请先登录注册