论坛风格切换切换到宽版
  • 1117阅读
  • 0回复

[问题求助]IPtable 1.0.7指南(四) 转 [复制链接]

上一主题 下一主题
离线jjp1.
 
发帖
2066
C币
-60377
威望
392
贡献值
1
银元
-2
铜钱
4743
人人网人气币
0
只看楼主 正序阅读 使用道具 楼主  发表于: 2009-05-01
使用赋值的 IP's的奇怪的ISP.'s 投资
我增加了这个是因为我的一个朋友告诉我我几乎忘光了的一件事,一些愚蠢的ISP's为他们的本地网 使用用IANA 赋值的IP's 。例如瑞典的ISP 和电话垄断者Telia在他们的DNS .服务器上使用.这种方法,使用10.x.x.x IP. 范围。你最可能遇到的问题是,在这个脚本中我们不允许任何在10.x..x.x范围内的IP's .到我们的连接,因为可能有欺骗。好,这有个例子.,你在那些规则上的花些力气。你可能在欺骗部分插入一个ACCEPT 规则,允许来自那些DNS 服务器的负载,或者你可以注释那部分脚本。它看起来象这样: 虚拟主机
/usr/local/.sbin/iptables -t nat -I .PREROUTING -i eth1 -s 10.0..0.1/32 –j ACCEPT            女人
我将咒骂这些ISP's。这个.范围不是为.你用来做填充的,.至少在我的知识范围内不是,对于大的公司站点更不是,或者对于你的家庭网络,但你不能迫使我们开放自己只因为你的一些whince 。 投资


更新并刷新你的表
如果你弄乱.了你的iptables,有命令可以刷新它,你不必要重启动。到现在为止我遇到这个问题好多次了,所以我想我将在这回答它。如果你错误地增加了一条规则,你可以在你加错的那一行上将-A 参数改为-D,iptables 将发现错误行并替你抹去,万一你有.几行看起来相同,它抹去它发现的与你的规则匹配的第一个实例。如果这不是你.想要的行为,你.就要试着使用-D 选项,iptables -D INPUT 10,将INPUT链中的第十条规则抹.去。     健康
还有你想刷新整个链的.情况,这时你要执行-F 选项。比如iptables -F INPUT将抹去整.个INPUT. 链,虽然它不会改变默认规则。因此如果默认规则被置为“DR.OP” ,而且你想象上面一样使用,则你要阻塞整个INPUT链,重置链规则,象你置“DROP”一样做。例如iptables -P INPUT ACCEPT。            建材
我做了一个小的脚本 (作为附录).可以刷新并重置你的iptables,你在创建你的rc.fire.wa.ll文件时可以考虑使用。还.有一件事情,如果你在弄乱的表中变的混乱,这个脚本不会抹去它们,它只添加抹去它们需要的几行,但在这我不添加它们,因为弄乱的表在我的rc.firewall 脚本中不使用。 电影

其他的资源及连接
这是我获得信息的一些连接:
http://ods.dyndns.org/ipt_flow.html            女人
system contr.ol v.ia /proc etc 学习
The official site of i.ptables an.d netfilter (广告)
The official netf..ilter FAQ .
Ru.sty's Unreliable Guide to packet filte.ring .
Rusty's U.nreliable .Guide to Network Address Translation 服务器
Rusty's Unrelia.ble Netfilter Hacking H.OWTO .
N.etfilter user mail.ing-list .
当然,还包括iptables 的原.始资料,文档及帮助我.的人。 .

贡献者
我感谢下面的人在我.写这篇文章时对我的帮助: .
Fabrice. Marie, 修改我的语法及拼写. 感谢他将指南修改成 Doc.Book 格式并带有 make files等等。
Marc Boucher, .在使用状态匹配代码上给予了我很.大的帮助。 .
Frod.e. E. Nyboe,完善了 rc.firewall 的规则,在我重写ruleset时给了我很大灵感,使我引入了在同一.文件中使用多重表格的方法。* .
Chapman Brad, Alexander W. Janssen, 他们使我认识到,我在想包如何以它们显示的顺序穿.过基本的 NAT和 filt.ers tables时最初是.想错了。 <性病>
Michiel Branden.bur.g, Myles Uyema,帮助我书写一些状态匹配代码并使它们工作。 --------------彩票
Kent `Arte..ch' Stahre, 帮助我从绘图的烦琐工作中解脱出来,我知道我热中于绘图,但是你是我所知道.的绘图最好的人,还感谢你帮我检查指南的错误。 .
Jeremy `Spliffy' .Smith, 感谢在可.能扰乱人的素材上给我以暗示,感谢尝试它并检查我写的东西的错误。               乙肝
还有.所有我曾经谈过话、向他们询问过建议的朋友。 .

例子 r.c.firewall <>; .

#!/bin/sh
#
# rc.firewall - Initial SIMPLE IP Firewall test scr..ipt for 2.4.x            鲜花
#
# Author: Oskar Andr.e.asson              汽车
# (c) o.f BoingWorld.com, use at your own ris.k, do whatever you please            鲜花
with
# it a.s long as you do.n't distribute this without due credits to 域名
# Boin.gWorld.com 域名
#

###########
# Configuration options, these will sp.eed you up getti.ng this script to     健康
# wor.k with your o.wn setup.     美容

#
# your LAN's IP range and localhost IP. /24 means t.o only use. the first 服务器
24
# bits of the 32 bit IP adress. the s.ame as netmas.k 255.255.255.0     健康
#
# STATIC_IP is used by me to allow myself to. do any.thing to myself, 健康
might
# be a security risc but sometimes I want this. If .you don't. have a 虚拟主机
static
# .IP, I suggest not using this option at all for now but it's s.til .
# enable.d p.er default and will add some really nifty security bugs for .
all
# those who skips readin.g .the documentation=)            建材

LAN_IP_R.ANGE="192.168.0.0/24" .域名
LA.N_IP="192.168.0.2/32" .
L.AN_.BCAST_ADRESS="192.168.0.255/32" 学习
LOCA.LHOST_.IP="127.0.0.1/32" 外贸
STATIC._IP="194.236.5.0.155/32"     外汇
IN.ET_IFACE="eth0"            鲜花
LAN_IFA.CE="eth1" --------------彩票
IPTABLES="/usr/local/sbin/iptabl.es". --- 印刷

#########
# .Load all .required IPTables modules           婚庆
#

#
# Neede..d to initially load modules            建材
#
/sbin/depmod. -a [成人用品]

#
# Adds some ipt.ables .targets like LOG, REJECT and MASQUARADE.              电子
#
/sbin/modp.robe ipt_LOG (        游戏          )
#./sbin/modprobe ipt_REJECT .            杀毒
/sbin/modpro.be ipt_MA.SQUERADE 外贸

#
# S.upport for owner matchin.g --- 印刷
#
#./.sbin/modprobe ipt_owner            鲜花

#
# Support for connection tracking .of FTP an.d IRC. 服务器
#
#/sbin/modprobe ip_conntrac.k_ft.p            女人
#/sbin../modprobe ip_conntrack_irc (        游戏          )

#
# Enable ip_forward, this is critical sinc.e it is tu.rned off as defaul <性病>
in Linux.
#

echo "1" >; ../proc/sys/net/ipv4/ip_forward 教育

#
# Dynamic IP users.: <性病>
#
#echo "1" >; /proc/sys./net/ipv4/ip_dynadd.r            建材

#
# Enable simple I.P Forw.arding and Masquerading --- 印刷
#

$IPTABLES -t nat -A POSTROUTING .-o $INET_IFACE -j MASQUERADE. --- 印刷

#
# Bad TCP packets .we .don't want            女人
#

$IP.TABLES -A FORWARD -p tcp. ! --syn -m state --state NEW -j LOG     外汇
--log-p.refix ".New not syn:" 电脑
$IPTABLES -A FORWARD -p tcp ! -.-syn -m state .--state NEW -j DROP" (        游戏          )

#
# Accept the packets we actual.ly want to forw.ard .
#

$IPTABLES -A FORWARD. -.i $LAN_IFACE -j ACCEPT (广告)
$IP.TABLES -A FORWARD -m sta.te --state ESTABLISHED,RELATED -j ACCEPT     外汇
$IPTABLES -A FORWAR.D -m limit --limit 3/minute --limit-burst 3. -j LOG .
--log-level DEBUG --log-pref.ix "IPT FORW.ARD packet died: " .

#
# Set default policies for .the INPUT, FORWARD and OU.TPUT chains .
#

$IPTABLES -P IN.PUT DROP [成人用品]
$.IPTABLES -P OUTPUT DROP               乙肝
$IPTABLES .-P. FORWARD DROP (        游戏          )

#
# C.reate separate c.hains for ICMP, TCP and UDP to traverse (        游戏          )
#

$IPTABLES -N ic.mp._packets <性病>
$IPTABLES -N tcp_.packets 教育
$IPTABLES -N udpincoming_pack.et.s 学习

#
# The allowed c.hain for TCP co.nnections              汽车
#

$IPTABLES -N all.owed (广告)
$IPTABL.ES -A allo.wed -p TCP --syn -j ACCEPT .
$IPTAB.LES -A allow.ed -p TCP -m state --state ESTABLISHED,RELATED -j <性病>
ACCEPT
$IPTABLES -A allowed -p TCP -j D.R.OP     美容

#
# ICMP rules
#

$IPTABLES -A icmp_packets .-p ICMP -s 0/.0 --icmp-type 0 -j ACCEPT 学习
$IPTABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type. 3 -j ACCEPT. 健康
$IPTABLES -A icmp_packets .-p ICMP -s. 0/0 --icmp-type 5 -j ACCEPT
$IP.TABLES -A icmp_packets -p ICMP -s 0/0 --icmp-type .11 -j ACCEPT            建材

#
# TCP rules
#

$IPTABLES -A tcp_pa.ckets -p TCP -s 0/0 .--dport 21 -j allowed [成人用品]
$IPTABLES -A tcp_packets -p TCP -s 0/.0. --dport 22 -j allowed     外汇
$IPT.ABLES -A tcp_packets -p TCP -s 0/0. --dport 80 -j allowed 服务器
$IPTABLES -A tcp_packets -p TCP -s 0/0 --dport 113 -j allowe..d     美容

#
# UDP ports
#

$IPTABLES -A udpincoming._packet.s -p UDP -s 0/0 --source-port 53 -j --------------彩票
ACCEPT
$IPTABLES -A udpincom.ing_packets -p UDP -.s 0/0 --source-port 123 -j 虚拟主机
ACCEPT
$IPTABLES -A udpincomi.ng_pack.ets -p UDP -s 0/0 --source-port 2074 -j     外汇
ACCEPT
$IPTABLES -A udpincoming_.packets -p UDP -s 0/0 --source-port .4000 -j
ACCEPT
评价一下你浏览此帖子的感受

精彩

感动

搞笑

开心

愤怒

无聊

灌水
快速回复
限100 字节
批量上传需要先选择文件,再选择上传
 
上一个 下一个