热门关键字:  ubuntu  分区  Fedora  linux系统进程  函数

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

来源: 作者: 时间:2007-10-17 Tag: 点击:

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



相关文章:
eG Citrix 监控器
Ethernet的帧格式和结构
华为(Quidway AR18-22-24)路由器配置实例
简单利用路由黑洞解决DDOS流量攻击
我的linux试验题目
如何在HMC上激活网络时间协议NTP
Resin泛解析 - 三级域名最优应用方案
Resin多域名绑定 + 泛解析
resin 负载均衡
linksys wap54g 设置注意事项
acegi RememberMe&退出&匿名登陆
vnd命令~
LINUX网卡绑定
TCP包首部
IP包首部格式
指纹锁也不靠谱 电脑“破解”六大事件!
linux配置网关
使用 SCTP 优化网络
IPv4/IPv6过渡技术和方案分析
用三个源码包libnet、libnids、libpcap轻松搭建Li
Extensible Messaging and Presence Protocol (XM
组建CISCO多层交换网络入门
CISCO多层交换机的初始配置和排错
实施和配置VLAN
理解和配置802.1Q/802.1S和802.1W生成树协议
理解和配置cisco特定的生成树协议特性和STP排错
配置第二层和第三层的特性
理解和配置VLAN间的路由选择
理解和配置多层交换
理解和配置cisco多层交换网络中的服务质量