Linux下永久关闭防火墙操作方法及其他方法

  • Post author:
  • Post category:linux




1–首先查看防火墙状态:

service iptables status

[root@localhost rabbitmq]# service iptables status  
Table: filter
Chain INPUT (policy ACCEPT)
num  target     prot opt source               destination         
1    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           state RELATED,ESTABLISHED 
2    ACCEPT     icmp --  0.0.0.0/0            0.0.0.0/0           
3    ACCEPT     all  --  0.0.0.0/0            0.0.0.0/0           
4    ACCEPT     tcp  --  0.0.0.0/0            0.0.0.0/0           state NEW tcp dpt:22 
5    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
num  target     prot opt source               destination         
1    REJECT     all  --  0.0.0.0/0            0.0.0.0/0           reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
num  target     prot opt source               destination   
显然是开启状态



2–永久性生效,重启后不会复原



1开启:

chkconfig iptables on  



2关闭:

chkconfig iptables off  



3.即时生效,重启后复原



1开启:

[root@localhost rabbitmq]# service iptables start



2关闭:

[root@localhost rabbitmq]# service iptables stop

[root@localhost rabbitmq]# service iptables stop  
iptables: Setting chains to policy ACCEPT: filter [  OK  ]
iptables: Flushing firewall rules: [  OK  ]
iptables: Unloading modules: [  OK  ]



4.设置后重启:

[root@localhost rabbitmq]# reboot

   Broadcast message from root@localhost
        (/dev/pts/0) at 23:21 ...

   The system is going down for reboot NOW!



5–linux查看防火墙状态及开启关闭命令 存在以下两种方式:

一、service方式

查看防火墙状态:service iptables status

iptables:未运行防火墙。


开启防火墙: service iptables start

关闭防火墙: service iptables stop


二、iptables方式

先进入init.d目录,命令如下:

[root@centos6 ~]# cd /etc/init.d/

[root@centos6 init.d]#

然后

查看防火墙状态:

[root@centos6 init.d]# /etc/init.d/iptables status

暂时关闭防火墙:

[root@centos6 init.d]# /etc/init.d/iptables stop

重启iptables:

[root@centos6 init.d]# /etc/init.d/iptables restart



版权声明:本文为qq_39205129原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。