2.试验拓扑:
1.jpg (17.48 KB)
2009-10-26 09:16
图中的『3接口路由器』可以用WIN2K或LINUX系统启动IP转发替代。
3.OPENBSD网络设置:
Fxp0: 192.168.0.100 Ne3: 192.168.1.100 Gateway: 192.168.0.1
4.PF规则:
# vi /etc/pf.conf
=================================================
if_isp1="fxp0"
if_isp2="ne3"
gw_isp1="192.168.0.1" gw_isp2="192.168.1.10"
block all
pass quick on lo0 all
pass in quick on $if_isp1 reply-to ( $if_isp1 $gw_isp1 ) proto{tcp,udp,icmp} to any keep state pass in quick on $if_isp2 reply-to ($if_isp2 $gw_isp2 ) proto {tcp,udp,icmp} to any keep state
pass out keep state
=================================================
为了试验方便,以上PF规则没有对TCP/UDP等协议的端口进行限制。大家根据自己的实际情况修改一下即可。为了方便控制PF的启动和关闭,下面列出我使用的一个SHELL脚步:
# vi /etc/rc.d/pf.sh
=================================================
#!/bin/sh
# made by llzqq
# pf startup scripts
#
case "$1" in
start)
if [ -f /etc/pf.conf ]; then /sbin/pfctl -e -f /etc/pf.conf
fi
stop)
/sbin/pfctl -F all
/sbin/pfctl -d
*)
echo "$0 start | stop"
esac
exit 0