Welcome 微信登录
编程资源 图片资源库 蚂蚁家优选 PDF转换器

首页 / 操作系统 / Linux / Linux下配置IPTABLES步骤

如果你Linux下的IPTABLES基础知识还不了解,建议先去看看.开始配置我们来配置一个filter表的防火墙.(1)查看本机关于IPTABLES的设置情况[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target       prot opt source                 destination         Chain FORWARD (policy ACCEPT)
target       prot opt source                 destination         Chain OUTPUT (policy ACCEPT)
target       prot opt source                 destination         Chain RH-Firewall-1-INPUT (0 references)
target       prot opt source                 destination        
ACCEPT       all    --    0.0.0.0/0              0.0.0.0/0          
ACCEPT       icmp --    0.0.0.0/0              0.0.0.0/0             icmp type 255
ACCEPT       esp    --    0.0.0.0/0              0.0.0.0/0          
ACCEPT       ah     --    0.0.0.0/0              0.0.0.0/0          
ACCEPT       udp    --    0.0.0.0/0              224.0.0.251           udp dpt:5353
ACCEPT       udp    --    0.0.0.0/0              0.0.0.0/0             udp dpt:631
ACCEPT       all    --    0.0.0.0/0              0.0.0.0/0             state RELATED,ESTABLISHED
ACCEPT       tcp    --    0.0.0.0/0              0.0.0.0/0             state NEW tcp dpt:22
ACCEPT       tcp    --    0.0.0.0/0              0.0.0.0/0             state NEW tcp dpt:80
ACCEPT       tcp    --    0.0.0.0/0              0.0.0.0/0             state NEW tcp dpt:25
REJECT       all    --    0.0.0.0/0              0.0.0.0/0             reject-with icmp-host-prohibited
可以看出我在安装linux时,选择了有防火墙,并且开放了22,80,25端口.如果你在安装linux时没有选择启动防火墙,是这样的[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target       prot opt source                 destination         Chain FORWARD (policy ACCEPT)
target       prot opt source                 destination         Chain OUTPUT (policy ACCEPT)
target       prot opt source                 destination  什么规则都没有.(2)清除原有规则.不管你在安装linux时是否启动了防火墙,如果你想配置属于自己的防火墙,那就清除现在filter的所有规则.[root@tp ~]# iptables -F        清除预设表filter中的所有规则链的规则
[root@tp ~]# iptables -X        清除预设表filter中使用者自定链中的规则我们在来看一下[root@tp ~]# iptables -L -n
Chain INPUT (policy ACCEPT)
target       prot opt source                 destination         Chain FORWARD (policy ACCEPT)
target       prot opt source                 destination         Chain OUTPUT (policy ACCEPT)
target       prot opt source                 destination      什么都没有了吧,和我们在安装linux时没有启动防火墙是一样的.(提前说一句,这些配置就像用命令配置IP一样,重起就会失去作用),怎么保存.[root@tp ~]# /etc/rc.d/init.d/iptables save这样就可以写到/etc/sysconfig/iptables文件里了.写入后记得把防火墙重起一下,才能起作用.[root@tp ~]# service iptables restart现在IPTABLES配置表里什么配置都没有了,那我们开始我们的配置吧(3)设定预设规则[root@tp ~]# iptables -p INPUT DROP[root@tp ~]# iptables -p OUTPUT ACCEPT[root@tp ~]# iptables -p FORWARD DROP
  • 1
  • 2
  • 下一页
黑客入侵Linux操作系统实例分析Linux ES5下安装clamav杀毒软件及使用方法相关资讯      IpTables 
  • CentOS Samba 服务器 Iptables 和   (今 07:14)
  • iptables超全详解  (09月01日)
  • Iptables防火墙 基础知识  (08月19日)
  • Iptables工作原理使用详解  (09月06日)
  • iptables中NAT表  (08月25日)
  • Linux 为FTP 服务器添加iptables规  (08月11日)
本文评论 查看全部评论 (0)
表情: 姓名: 字数


评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑