lsstarboy 发表于 2015-01-07 14:18

回复 9# qjsyjy


    每个fib可以设置一个网关。不懂pf,只懂ipfw。

qjsyjy 发表于 2015-01-07 16:51

回复 11# lsstarboy


ipfw也行,有相关实例或链接吗?想学习一下,谢谢。

lsstarboy 发表于 2015-01-07 23:38

回复 12# qjsyjy


    我还没用到双线,但是应该不是很麻烦,最大的困难是分清电信和联通的IP地址段,策略路由主要是在目标地址上,大致的语句应该是:

ipfw add setfib "fibnum" ip from any to "电信IP段"

或者用table,table的实例在ipfw man中可以找到。

webmasters 发表于 2015-01-27 10:13

很久以前我看到有人做过,你说的这个用策略路由可以实现。

yyu0378 发表于 2015-01-27 10:23

用路由表就成,但是ip段很难确定。最好吧用的少的不设定网关,减少工作量

williamy 发表于 2015-01-27 12:05

hahahahahahaahahahahahahaahahahahahahaahahahahahahaa

zero-B 发表于 2015-01-27 20:20

FreeBSD 的双线一直还没机会去设置,不过在单位倒是设了 WIN 7 的双线,可以把思路换过去试试:

比如现在有电信和联系的双线,默认走电信线路,那就把 default_gateway 设成电信的网关,那要走联通线路的 IP 就改路由表来实现。

iceblood 发表于 2015-02-01 20:34

07年我收集的一段PF实现文章,你照着试试看。
lan_net = "192.168.0.0/24"
int_if = "dc0"
ext_if1 = "fxp0"
ext_if2 = "fxp1"
ext_gw1 = "68.146.224.1"
ext_gw2 = "142.59.76.1"

# nat outgoing connections on each internet interface
nat on $ext_if1 from $lan_net to any -> ($ext_if1)
nat on $ext_if2 from $lan_net to any -> ($ext_if2)

# default deny
block in from any to any
block out from any to any

# pass all outgoing packets on internal interface
pass out on $int_if from any to $lan_net
# pass in quick any packets destined for the gateway itself
pass in quick on $int_if from $lan_net to $int_if
# load balance outgoing tcp traffic from internal network.
pass in on $int_if route-to { ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin proto tcp from $lan_net to any flags S/SA modulate state
# load balance outgoing udp and icmp traffic from internal network
pass in on $int_if route-to { ($ext_if1 $ext_gw1), ($ext_if2 $ext_gw2) } round-robin proto { udp, icmp } from $lan_net to any keep state

# general "pass out" rules for external interfaces
pass out on $ext_if1 proto tcp from any to any flags S/SA modulate state
pass out on $ext_if1 proto { udp, icmp } from any to any keep state
pass out on $ext_if2 proto tcp from any to any flags S/SA modulate state
pass out on $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 on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to any
pass out on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any

Machm 发表于 2015-02-17 23:19

作服务的方面,用pf防火墙,设置数据包从哪个网卡进来,就从那个网卡出去就行;FB系统自身连外网方面,比如,系统更新、ports更新,当然是走默认路由那条线路,我的是校园网+电信的双线环境,所以默认路由,用电信线路的方便。FB系统连校园网其他服务器的,设几条静态路由就行了。

lsstarboy 发表于 2015-02-19 16:19

很多人都没理解“双线”的含义,“双线”不是基础路由能完成的任务,双线除了BGP外,就应该是“策略路由”。严格来说有两种,双线上网应该叫“目的策略路由”;双线服务器就是上面两位说的从哪个网卡来的再从哪个网卡出去(不是完全对,大部分是),叫“源地址策略路由”。策略路由就必须借助fib实现,route本身是不行的。
页: 1 [2]
查看完整版本: FreeBSD双线双IP应该怎么设置?