- 论坛徽章:
- 0
|
讨论一下,暂时没条件测试:
# vi /etc/rc.conf
================+==============+=================
ifconfig_rl0="inet 218.104.232.207 netmask 255.255.255.0" //网通
ifconfig_rl1="inet 61.154.11.150 netmask 255.255.255.0" //电信
pf_enable="YES"
================+==============+=================
# vi /etc/pf.conf
================+==============+=================
##anchors
ext_if1 = "rl0"
ext_if2 = "rl1"
ext_gw1 = "218.104.232.1"
ext_gw2 = "61.154.11.254"
loop = "lo0"
service = "{22, 80, 443}"
scrub in all
antispoof for {$ext_if1, $ext_if2} inet
##default deny
block all
block return
##general "pass in" rules for external and loop interfaces
pass quick on $loop all
pass in on {$ext_if1, $ext_if2} proto tcp from any to any port $service flags S/SA modulate state
pass in on {$ext_if1, $ext_if2} proto { udp, icmp } from any to any keep state
##general "pass out" rules for external interfaces
pass out on {$ext_if1, $ext_if2} proto tcp from any to any flags S/SA modulate state
pass out on {$ext_if1, $ext_if2} proto { udp, icmp } from any to any keep state
##route packets from any IPs on $ext_if1 to $ext_gw1 and the same for
##$ext_if2 and $ext_gw2
pass out quick on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to any
pass out quick on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any
================+==============+=================
这个教本参考了pf的faq写的。实现双线接入情况下,从网通专线来的IP包,回去的时候还走网通线路,同理,电信线路来的IP包回去的时候还走电信线路。大家帮我分析一下,这个教本实现的思路有没有问题。
下面这个是网上参考别人的思路来的,给IP包打了标记,IP包出去的时候根据原先打的标记判断IP包的出口是那个:
给IP包打标记的策略路由方法:
##anchors
ext_if1 = "rl0" //接网通
ext_if2 = "rl1" //接电信
ext_gw1 = "218.104.232.1" //网通网关
ext_gw2 = "61.154.11.254" //电信网关
loop = "lo0"
service = "{22, 80, 443}"
scrub in all
antispoof for {$ext_if1, $ext_if2} inet
##default deny
block all
block return
##general "pass in" rules for external and loop interfaces
pass quick on $loop all
pass in on $ext_if1 tag cncgroup keep state
pass in on $ext_if2 tag chinanet keep state
##general "pass out" rules for external interfaces
pass out on {$ext_if1, $ext_if2} proto tcp from any to any flags S/SA modulate state
pass out on {$ext_if1, $ext_if2} proto { udp, icmp } from any to any keep state
##route packets from any IPs on $ext_if1 to $ext_gw1 and the same for
##$ext_if2 and $ext_gw2
pass out quick on $ext_if1 route-to ($ext_if2 $ext_gw2) tagged chinanet keep state
pass out quick on $ext_if2 route-to ($ext_if1 $ext_gw1) tagged cncgroup keep state
[ 本帖最后由 llzqq 于 2006-11-30 17:20 编辑 ] |
|