一:安装iptablse防火墙
yum install iptables-services -y
二:配置开机启动
systemctl enable iptables
三:配置防火墙
vi /etc/sysconfig/iptables
配置相关如下(这里开启了8080和3306端口)
# Firewall configuration written by system-config-firewall Linux学习,http:// linux.it.NET.cn
# Manual customization of this file is not recommended.
*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0] Linux学习,http:// linux.it.Net.cn
-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT
-A INPUT -m state --state NEW -m tcp -p tcp --dport 3306 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
:wq
#保存退出
四:重启
systemctl restart iptables.service
systemctl enable iptables.service
Iptables
最新推荐文章于 2025-07-17 00:20:59 发布
3273

被折叠的 条评论
为什么被折叠?



