目录
一、常用配置
1) 永久性生效,重启后不会复原
开启: chkconfig iptables on
关闭: chkconfig iptables off
2) 即时生效,重启后复原
开启: service iptables start
关闭: service iptables stop
查看防火墙状态 :service iptables status 或 iptables -L -n
防火墙打开3306端口
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT
/etc/rc.d/init.d/iptables save
/etc/init.d/iptables status
linux查看端口被哪个进程占用 lsof -i:端口号
查看Linux服务器的版本 lsb_release -a
查看当前iptables(防火墙)规则 iptables -L -n
添加指定端口到防火墙中 iptables -I INPUT -p 协议 --dport 端口号 -j ACCEPT
iptables -A INPUT -d 224.0.0.18 -j ACCEPT keepalived
/sbin/iptables -I INPUT -p tcp --dport 3306 -j ACCEPT mysql
/sbin/iptables -I INPUT -p tcp --dport 80 -j ACCEPT nginx
/sbin/iptables -I INPUT -p tcp --dport 15672 -j A

本文详细介绍了Linux系统中iptables的基本配置,包括开启、关闭防火墙,添加规则以及查看状态等操作。同时,讲解了CentOS7中firewalld的使用,如何启动、关闭以及添加端口。最后,讲述了如何在CentOS7中从firewalld切换回iptables,并进行了相关配置步骤的说明。
最低0.47元/天 解锁文章

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



