首页 | 互联网 | IT动态 | Cisco | Windows | Linux | Java | .Net | Oracle | 华为 | 存储世界 | 服务器 | 网络设备 | IDC | 安全 | 求职招聘
IT培训 | 数字网校 | 技术专题 | 电子书下载 | 教学视频 | 网页设计 | 平面设计 | 解决方案 | 直播室 | 虚拟考场 | 搜索 | 博客 | 沙龙 | 论坛
中国IT实验室Linux频道
中国IT教育
首页 新手入门 Linux编程 系统管理 网络管理 Linux认证 Unix/BSD Linux数据库 Linux集群 Linux手册 Linux下载 论坛 专题 RSS
您现在的位置: 中国IT实验室 >> Linux >> 网络管理 >> Linux安全 >> 文章正文

Linux系统下IPtables防火墙简易设置方法

文章来源中国IT实验室收集整理 作者佚名 更新时间2007-10-17 保存本文保存本文 推荐给好友推荐给好友 收藏本页收藏本页

  iptables.rule为firewall总规则;

  iptables.allow为充许进入的主机;

  iptables.deny为不许放的主机;

  iptables.allow代码如下:

  #!/bin/bash

  # This is an esay firewall.

  # the inside interface. if you don't have this one

  # and you must let this be black ex> INIF=""

  INIF="eth0"

  INNET="192.168.160.0/20"

  # 2.0 load the right module

  PATH=/sbin:/bin:/usr/sbin:/usr/bin

  export PATH EXTIF INIF INNET

  modprobe ip_tables > /dev/null 2>&1

  modprobe iptable_nat > /dev/null 2>&1

  modprobe ip_nat_ftp > /dev/null 2>&1

  modprobe ip_nat_irc > /dev/null 2>&1

  modprobe ip_conntrack > /dev/null 2>&1

  modprobe ip_conntrack_ftp > /dev/null 2>&1

  modprobe ip_conntrack_irc > /dev/null 2>&1

  # 3.0 clear iptables rule

  /sbin/iptables -F

  /sbin/iptables -X

  /sbin/iptables -Z

  /sbin/iptables -F -t nat

  /sbin/iptables -X -t nat

  /sbin/iptables -Z -t nat

  /sbin/iptables -P INPUT DROP

  /sbin/iptables -P OUTPUT ACCEPT

  /sbin/iptables -P FORWARD ACCEPT

  /sbin/iptables -t nat -P PREROUTING ACCEPT

  /sbin/iptables -t nat -P POSTROUTING ACCEPT

  /sbin/iptables -t nat -P OUTPUT ACCEPT

  # 4.0 start loading trusted and denied file.

  if [ -f /usr/local/virus/iptables/iptables.allow ]; then

  sh /usr/local/virus/iptables/iptables.allow

  fi

  if [ -f /usr/local/virus/iptables/iptables.deny ]; then

  sh /usr/local/virus/iptables/iptables.deny

  fi

  # 5.0 if the following file exist ,please executed

  if [ -f /usr/local/virus/httpd-err/iptables.http ];then

  sh /usr/local/virus/httpd-err/iptables.http

  fi

  # 6.0 allow icmp data packet and the establishd data

  /sbin/iptables -A INPUT -m state ——state ESTABLISHED,RELATED -j ACCEPT

  AICMP="0 3 3/4 4 11 12 14 16 18"

  for tyicmp in $AICMP

  do

  /sbin/iptables -A INPUT -i $EXTIF="eth0" -p icmp ——icmp-type $tyicmp -j ACCEPT

  done

[1] [2] 下一页  

【责编:Yoyo】
中国IT教育
相关产品和培训
文章评论
 友情推荐链接
 专题推荐

 ·Linux 安全管理
 ·Linux 下DNS服务器架设攻略
 ·Linux 下的路由的配置与应用
 ·专题:Apache实用手册
 ·全面剖析Linux文件系统
 ·Linux常用命令全集
 ·GRUB 玩转任意操作系统多重启动引导
 ·想传就传 多平台随心所欲架设FTP
 ·网络圈地 建立企业web服务器专题
 ·Linux安装指南专题
 今日更新
 认证培训
 频道精选
 Windows频道导航