新闻中心

EEPW首页>手机与无线通信>设计应用> Freebsd PF实现策略路由案例

Freebsd PF实现策略路由案例

作者: 时间:2011-07-22 来源:网络 收藏

1.说明: 此方案适用于可以使用做为防火墙的操作系统,包括FREEBSD/OPENBSD/NETBSD。所谓的就是在服务器同时连接了两个ISP线路,从那个网卡进来的数据包请求,返回给CLIENT时还从那个网卡出去。
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.规则:
# 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
=================================================
为了试验方便,以上规则没有对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

本文引用地址://m.amcfsurvey.com/article/156013.htm


评论


相关推荐

技术专区

关闭