成人在线你懂的-成人在线免费小视频-成人在线免费网站-成人在线免费视频观看-日韩精品国产一区二区-日韩精品国产一区

掃一掃
關(guān)注微信公眾號

Linux系統(tǒng)下IPtables防火墻簡易設(shè)置方法
2007-10-29   賽迪網(wǎng)

iptables.rule為firewall總規(guī)則;

iptables.allow為充許進(jìn)入的主機(jī);

iptables.deny為不許放的主機(jī);

◆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

# 7.0 open the other service ports

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 25 -j ACCEPT # SMTP

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 53 -j ACCEPT # DNS

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 80 -j ACCEPT # WWW

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 110 -j ACCEPT # POP3

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 113 -j ACCEPT #AUTH

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 22222 -j ACCEPT #SSH

/sbin/iptables -A INPUT -p UDP -i $EXTIF="eth0" --dport 138 -j ACCEPT #138

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 139 -j ACCEPT #139

/sbin/iptables -A INPUT -p UDP -i $EXTIF="eth0" --dport 137 -j ACCEPT #137

/sbin/iptables -A INPUT -p TCP -i $EXTIF="eth0" --dport 445 -j ACCEPT #445

◆iptables.allow代碼如下

#!/bin/bash

# this program is used to allow some IP or hosts to access your server

/sbin/iptables -A INPUT -i $EXTIF="eth0" -s 192.168.161.242 -j ACCEPT

/sbin/iptables -A INPUT -i $EXTIF="eth0" -s 192.168.160.178 -j ACCEPT

/sbin/iptables -A INPUT -i $EXTIF="eth0" -s 192.168.160.218 -j ACCEPT

iptables.deny代碼如下

#! /bin/bash

# This script will deny some IPs that I don't want in IN

/sbin/iptables -A INPUT -i $EXTIF="eth0" -s 192.168.160.242 -j DROP

以上的三個文件都放在/usr/local/virus/iptables目錄下,最在修改此文件/etc/rc.d/rc.local成如下代碼。

#!/bin/sh

#

# This script will be executed *after* all the other init scripts.

# You can put your own initialization stuff in here if you don't

# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local

# Starting firewall settings

/usr/local/virus/iptables/iptables.rule

以上就是linux下firewall簡易設(shè)置啦。

熱詞搜索:

上一篇:扮靚Windows側(cè)邊欄 讓Vista的桌面更可愛
下一篇:Ubuntu 7.04下安裝虛擬機(jī)VMware Server

分享到: 收藏
主站蜘蛛池模板: 仪铭| 广州打折网| 阿妹的诺言| 闺蜜心窍 电影| 女生下体长什么样| 叶子楣作品| 假面骑士电王| 法医秦明之幸存者 2018 经超| 黄色网址视频免费| 四川旅游攻略| 都市女孩| 护学岗值班记录表| 三年片在线观看电影在线观看大全| 忘记年龄,讨好自己,用自己喜欢的方式生活| 电影不知不觉诱惑你| 上门女婿电视剧演员| 当代大学德语2答案| 赛虎| 爱情秘密| 三人行菲律宾| 唐安琪视频| 皮囊之下| 福音电影| 美女自卫网站| baekhyun| 妻子的秘密在线| 浙江卫视今天全部节目表| 美丽的坏女人中文字幕| 周传雄黄昏歌词| 三年片大全电影| 周杰伦雨下一整晚歌词| 青山知可子冲绳草莽英雄1969| 梁山伯与祝英台电影| 易烊千玺个人资料简介| 叠影危情| 小数加减法100道题| dj歌曲串烧中文大全| 谷桃子| 科室对分级护理落实情况检查记录| 陈程玉| 三大|