Linux关闭防火墙命令
Linux命令
systemctl ------centos7
service ------centos6
1:查看防火状态
systemctl status firewalld
1
service iptables status
12:暂时关闭防火墙
systemctl stop firewalld
1
service iptables stop
13:永久关闭防火墙
systemctl disable firewalld
12
chkconfig iptables off
14:重启防火墙
systemctl enable firewalld
1
service iptables restart
15:永久关闭后重启
//暂时还没有试过
chkconfig iptables on
1、查看防火墙状态
[root@instance-xfl1djr7 ~]# /etc/init.d/iptables status
2、启动/关闭防火墙
开启防火墙
[root@instance-xfl1djr7 ~]# service iptables start
关闭防火墙
[root@instance-xfl1djr7 ~]# service iptables stop
开机自启
开启: chkconfig iptables on
关闭: chkconfig iptables off
3、开放指定端口
比如我要开放3306三个端口,可以在/etc/sysconfig/iptables文件中添加三行信息,如下:
vi /etc/sysconfig/iptables
内容修改成如下:
# Firewall configuration written by system-config-firewall
# Manual customization of this file is not recommended.*filter
:INPUT ACCEPT [0:0]:FORWARD ACCEPT [0:0]:OUTPUT ACCEPT [0:0]-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 3306-j ACCEPT
-A INPUT -j REJECT –reject-withicmp-host-prohibited
-A FORWARD -j REJECT –reject-withicmp-host-prohibited
COMMIT
修改后重启防火墙
service iptables restart
CentOS6/7系统中防火墙默认是阻止3306端口的
Centos6
我们要是想访问mysql数据库,我们需要这个端口,命令如下:
/sbin/iptables -I INPUT -p tcp --dport 3306-j ACCEPT
我们需要保存我们的操作,命令如下:
/etc/rc.d/init.d/iptables save
此时我们可以查看端口的状态,命令如下:
/etc/init.d/iptables status