第十八讲:防火墙设置.pptVIP

  • 1
  • 0
  • 约6.69千字
  • 约 30页
  • 2017-06-27 发布于湖北
  • 举报
iptables命令参数 iptables命令参数: -p [!]protocol 指定协议 -s [!]address [/mask] 指定源IP地址 -d [!]address [/mask] 指定目标IP地址 -j target 指定跳转目标(动作/自定义规则链) -i [!] name 指定进接口 -o [!] name 指定出接口 --sport port 指定源端口 --dport port 指定目标端口 --sports port[,port[,port...]] 指定多个源端口 --dports port[,port[,port...]] 指定多个目录端口 --ports port[,port[,port...]] 指定多个双向端口 --icmp-type [!] typename 指定icmp类型 --mac-source [!] address 指定源MAC地址 --tcp-flags [!] mask comp 指定TCP协议标志 … iptables命令的使用(一) 查看规则表的内容 基本语法: iptables [-t table] -L [chain] [options] 不指定表名称时查看filter表的内容 #iptables -L 查看指定的规则表 #iptables -t filter -L #iptables -t nat -L #iptables -t mangle -L iptables命令的使用(二) 清空表中的规则 命令格式: iptables [-t table] -F [chain] [options] 清空filter表中的所有规则 # iptables -F 清空指定表中的所有规则 #iptables -t filter -F #iptables -t nat -F #iptables -t mangle -F iptables命令的使用(三) 删除表中的自定义规则链 命令格式: iptables [-t table] -X [chain] 删除filter表中的规则链 #iptables -X 删除指定表中的规则链 #iptables -t filter -X #iptables -t nat -X #iptables -t mangle -X iptables命令的使用(四) 设置默认规则: #iptables -t filter -P INPUT DROP #iptables -t filter -P FORWARD ACCEPT #iptables -t filter -P OUTPUT ACCEPT #iptables -t nat -P PREROUTING ACCEPT … #iptables -t mangle -P PREROUTING ACCEPT … 只有内建规则链才能够设置“缺省策略” 将filter表的INPUT缺省策略设置为“DROP”,比较严谨 数据包的过滤由上至下进行 前允许后拒绝 两条规则都有效 前拒绝后允许 后条规则无效 iptables命令的使用(五) 添加规则: 命令格式: iptables [-t table] -A chain rule-specification [options] 在INPUT规则链中添加规则,允许来自“lo”网络接口中所有数据包 # iptables -A INPUT -i lo -j ACCEPT 在INPUT规则链中添加规则,允许“eth0”网络接口中来自“/24”子网的所有数据包 # iptables -A INPUT -i eth0 -s /24 -j ACCEPT iptables命令的使用(六) 删除规则: 命令格式: iptables [-t table] -D chain rule-specification [options] 删除规则的iptables命令与添加规则的命令格式类似 删除INPUT规则表中已有的规则 # iptables -D INPUT -i eth0 -s /24 -j ACCEPT 实例2-1 # iptables -F # iptables -X # iptables -Z # iptables -P INPUT DROP # iptables -A INPUT -i lo -j ACCEPT # iptables -A INPUT -i eth0 -p tcp --dport 22 -j ACCEPT # iptables -A INPUT -i eth0 -p tcp --dport 80 -j ACCEPT # iptables -A IN

文档评论(0)

1亿VIP精品文档

相关文档