Linux防火墙iptables命令及示例
CentOS 配置防火墙操作实例(启、停、开、闭端口):
注:防火墙的基本操作命令:
查询防火墙状态 : [root@localhost ~]# service iptables status
停止防火墙 : [root@localhost ~]# service iptables stop
启动防火墙 : [root@localhost ~]# service iptables start
重启防火墙 : [root@localhost ~]# service iptables restart
永久关闭防火墙 : [root@localhost ~]# chkconfig iptables off
永久关闭后启用 : [root@localhost ~]# chkconfig iptables on
iptables命令及示例如下:
-A, --append:新增规则到规则链中。
示例:iptables -A INPUT -p tcp --dport 80 -j ACCEPT
说明:新增规则到INPUT规则链中,允许所有目的端口为80的数据包的流入连接。
-D, --delete:从规则链中删除指定规则。
示例:iptables -D INPUT -p tcp --dport 80 -j ACCEPT
说明:删除INPUT规则链中允许所有目的端口为80的数据包的流入连接的规则。
-R, --replace:替换规则链中的规则。
示例:iptables -R INPUT 1 -s 192.168.0.1 -j DROP
说明:替换INPUT规则链中的第一条规则,将来自192.168.0.1的数据包丢弃。
上一条:IIS7如何装rewrite
下一条:iptables基础命令详解