Centos 6.x版本 iptables
- 查看防火墙状态:
[root@centos6 ~]# service iptables status
iptables: Firewall is not running.
说明防火墙没有开启。
- 开启防火墙:
[root@centos6 ~]# service iptables start
- 关闭防火墙:
[root@centos6 ~]# service iptables stop
Centos 7版本 firewall
背景:在CentOS上面安装了mysql、svn、tomcat等软件,发现访问不了,用telnet命令查看端口,发现都不通。
telnet IP 端口
操作系统环境:CentOS Linux release 7.0.1406(Core) 64位
CentOS7 默认使用firewalld防火墙.
开放特定端口:firewall-cmd --zone=public --add-port=8080/tcp --permanent
查看防火墙状态:firewall-cmd --state
重启防火墙:systemctl restart firewalld
查看端口列表:firewall-cmd --zone=public --list-ports
CentOS7 默认使用firewalld防火墙,如果想换回iptables防火墙,可关闭firewalld并安装iptables。
具体参考连接:https://www.jianshu.com/p/4b0afe75990e