使用iptables禁止特定子网访问指定端口
2025/8/28...小于 1 分钟
使用iptables禁止特定子网访问指定端口
目的
禁止来自 192.168.12.0/24 子网的设备通过 TCP 协议访问本机的 80、443 和 22 端口。
步骤
# 禁止 192.168.12.0/24 子网通过 TCP 协议访问本机的 80、443 和 22 端口
# 或者 iptables -A INPUT -s 192.168.12.0/24 -p tcp -m multiport --dports 80,443,22 -j REJECT --reject-with icmp-port-unreachable
iptables -t filter -A INPUT -s 192.168.12.0/24 -p tcp --dport 80 -j DROP
iptables -t filter -A INPUT -s 192.168.12.0/24 -p tcp --dport 443 -j DROP
iptables -t filter -A INPUT -s 192.168.12.0/24 -p tcp --dport 22 -j DROP
更新日志
2025/8/28 03:08
查看所有更新日志
8631e
-于