大家好
我用ipc.op 来做防火墙,目前只有两块网卡, 一块对外的red, 一.块对内的green, 现在默认情况下 .不能实现重 red到green的端口转发,所以很多服务没能发布出去. 有个脚本是关于iptables的, 我对iptables 只了.解大概, 大家一起帮忙看看投资
roo.t@ipcop:/etc/rc.d # more rc..firewall(广告)
#!/bin/sh
#
# $Id: rc.firewall,v 1.7.2.20 2006/01/12 01:24:30 fr.anck78. Exp $(广告)
#
eval $.(/usr/local/bin/readhash /va.r/ipcop/ppp/settings)--- 印刷
eval $(/usr/local/bin/read.hash /var/ipcop/ethernet/sett.ings)域名
IFACE=`/bin/ca.t /var/ipcop/red/iface 2> /.dev/null | /usr/bin/tr -d '\012'`<性病>
if .[ -f ./var/ipcop/red/device ]; then电影
. DEVICE=`/bin/cat /var/ipcop/red/device 2> ./dev/null | /usr/.bin/tr -d '\012'`健康
fi
iptables_i.nit() {.
# Flush all rule.s and delete all custom chain.s 电子
/sbin/ipta.bles -F.
/sbin/iptabl.es. -t nat -F电脑
/sbin/iptables -t man.gle. -F.
. /sbin/iptables -X 外汇
. ./sbin/iptables -t nat -X.
. /sbin/.iptables -t mangle -X 外汇
.# Set up policies电脑
/sbin/ip.tables -P INPUT DRO.P学习
/sbin/iptabl.es .-P FORWARD DROP--------------彩票
. . /sbin/iptables -P OUTPUT ACCEPT.
# Empty LOG_DROP .and LOG_REJECT cha.ins教育
. . /sbin/iptables -N LOG_DROP虚拟主机
/sbin/iptable.s -A LOG_DROP -m limit --limit 10/minute. -j LOG电脑
. /s.bin/iptables -A LOG_DROP -j DROP.
/s..bin/iptables -N LOG_REJECT.
/sbin/.iptables -A LOG_REJECT -m li.mit --limit 10/minute -j LOG健康
/sbin/iptables -A .LOG._REJECT -j REJECT( 游戏 )
# This c..hain will log, then DROPs packets with c.ertain bad combinations.
. # of flags might indicate a port-scan attempt (xmas, null, e.tc)
/sbin/i.ptables -N P.SCAN学习
/sbin./iptables -A PSCAN -p tcp -m limit --limit 10/minute -j LOG --log-prefix ".T.CP Scan? ".
/sbin./.iptables -A PSCAN -p udp -m limit --limit 10/minute -j LOG --log-prefix ".UDP Scan? " 女人
/sbin/ipta.bles -A PSCAN -p icmp .-m limit --li.mit 10/minute -j LOG --log-prefix "ICMP Scan? " 美容
. . /sbin/iptables -A PSCAN -f . -m limit --limit 10/minute -j LOG --log-prefix "FRAG Scan? " 电子
/sbin/.iptables -A P.SCAN -j DROP健康
# New tcp packets without SYN set - could wel.l be an obsc.ure type of .port scan 女人
# that's not. covered above, may just be a broken. windows machine.
/sbin/iptables .-.N NEWNOTSYN 外汇
. /sbin/iptables -A NEWNOTSYN -m limit --limit 10/minute -j LOG --log-pr.efix "NEW not SYN? ".--- 印刷
. /sbi.n/iptables -A NEWNOTSYN -j DROP 美容
# Chain to contain all. the rule.s relating to bad TCP flags学习
. /sbin/i.ptables -N BADTCP教育
# Disallow pa.ckets frequently used by p.ort-scanners 杀毒
# nmap x.mas.
/.sbin/iptables -A. B.ADTCP -p tcp --tcp-flags ALL FIN,URG,PSH -j PSCAN服务器
# Null
/s.bin/iptables .-A BADTCP -p tcp --tcp-flags ALL NONE -j PSCAN(广告)
# FIN
. /sbin/iptables .-A BADTCP -p tcp --tcp-flags ALL FIN -j PSCAN 健康
. # SYN/RST (also catches xmas variants that set SYN+RST.+...).
/sbi.n/iptables -A. BADTCP -p tcp --tcp-.flags SYN,RST SYN,RST -j PSCAN外贸
# SYN/FIN (QueSO or nma.p OS. probe).
. /sbi.n/iptables -A BADTCP -p tcp --tcp-flags SYN,FIN SYN,FIN .-j PSCAN.
. # NEW TCP with.out SYN健康
. /sbin/iptables -A BADTCP -p tcp .! --syn -m stat.e --state NEW -j NEWNOTSYN.
/sbin/iptables -A .I.NPUT -j BADTCP.
. /sbin/iptables -A FOR.WARD -j BADTCP 建材
}
iptables._red() {.
. /sbin/iptables -F REDINPUT. 建材
/sbi.n/i.ptables -F REDFORWARD<性病>
/sb.in/iptables .-t nat -F REDNAT 乙肝
. # PPPoE / PPTP Devic.e.
if [ ".$IFACE". != "" ]; then[成人用品]
. . # PPPoE / PPTP.
if [ ."$DEVICE" .!= "" ]; then服务器
./sbin/iptables -A REDINPUT -i $.DEVICE -j ACCEPT电影
. fi 电子
. if [ "$RED_TYPE" == "PPTP" -o "$RED_TYPE" == ".PPPOE" ]; th.en教育
if [ "$RED_D.EV" != "" ];. then服务器
. . /sbin/ipta.bles -A REDINPUT -i $RED_DEV -j ACCEPT fi<性病>
. fi.
fi
# P.PTP over DHCP 汽车
if [ ."$DEVICE". != "" -a "$TYPE" == "PPTP" -a "$METHOD" == "DHCP" .]; then. /sbin/iptables -A REDINPUT -p tcp -.-source-port 67 --destination-port 68 -i $DEVICE -j ACCEPT<性病>
. /sbin/iptables -A REDINPUT -p udp --source-port 67 --destinati.on-port 68 -i $DE.VICE -j ACCEPT 女人
fi
#. Orange pinholes<性病>
if [ "$ORANGE_DEV" !.= "". ]; then 健康
# This ru.le enables a host on ORANGE network to c.o.nnect to the outside健康
. # (only if we hav.e a red connection).
. . if [ "$IFACE" != "" ]; then.
.. /sbin/iptables -A REDFORWARD -i $ORANGE_DEV -p tcp -o. $IFACE -j ACCEPT虚拟主机
.. . /sbin/iptables -A REDFORWARD -i $ORANGE_DEV -p udp -o $IFACE -j ACCEPT 婚庆
. fi 建材
fi
if [ "$I.FACE". != "" -a -f /var/ipcop/red/active ]; then 鲜花
# DHC.P外贸
if [ "$RED_DEV" != "" .-a "$RED_TYPE" == "DHCP" ]; th.en电影
/sbin/iptables -A REDINPUT -p tcp --source-port 67. --des.tination-port 68 -i $IFACE -j AC.CEPT.
/sbin/iptab.les -A REDINPUT -p udp --source-port 67 --destination-por..t 68 -i $IFACE -j ACCEPT教育
. fi[成人用品]
if [ ".$METHOD" == "DHCP" -a "$P.ROTOCOL" == "RFC14.83" ]; then 健康
/sbin/i.ptables -A REDI.NPUT -p tcp --source-port 67 --destina.tion-port 68 -i $IFACE -j ACCEPT<性病>
/sbin/ipta.bles. -A REDINPUT -p udp --source-port 67 --destination-port. 68 -i $IFACE -j ACCEPT 建材
. fi.
. # Outgoing masquer.ading服务器
. /sbin/iptables -t nat -A REDNAT -.o $IFACE -j MASQUERADE电影
fi
}
复制代码