> Linux教程 > 系统运维 >

linux下防火墙的开启和关闭

操作系统:ubuntu 11.10 / CentOS 6.3

 

firewall_close.sh:

 

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
#!/bin/bash
 
#centos begin
 
#check the firewall status 
#/etc/init.d/iptables stutas 
 
#Temporary closed firewall
#/etc/init.d/iptables stop
 
#Permanent closed firewall
#chkconfig iptables off
 
#centos end
 
 
#ubuntu begin
 
#check the firewall status 
ufw status
 
#Temporary closed firewall
ufw disable
 
#ubuntu end
 
 
exit

 

 

firewall_open.sh:

 

 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/bin/bash
 
#centos begin
 
#check the firewall status 
#/etc/init.d/iptables stutas 
 
#Temporary closed firewall
#/etc/init.d/iptables start
 
#Permanent closed firewall
#chkconfig iptables on
 
#centos end
 
 
#ubuntu begin
 
#check the firewall status 
ufw status
 
#Temporary open firewall
ufw enable
 
 
#ubuntu end
 
 
exit



(责任编辑:IT)