免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 1922 | 回复: 2
打印 上一主题 下一主题

[FreeBSD] 关于pf的双线路配置的问题,高手请进! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2009-09-22 11:06 |只看该作者 |倒序浏览
我有两条电信的线路,pf配置如下
if_isp1="fxp1"
if_isp2="fxp2"
gw_isp1="218.2.115.118"
gw_isp2="218.94.117.178"
lan_net = "192.168.1.0/23"
int_if = "em0"

现在公司要求我,192.168.0.1-192.168.0.254从gw_isp1(218.2.115.118)这条路走,192.168.1.1-192.168.1.254从gw_isp2(218.94.117.178)这条路走,不需要负载均衡。
不知道pf.conf该怎么写?有高手帮帮忙,写个比较完整的配置。非常感谢!

论坛徽章:
0
2 [报告]
发表于 2009-09-22 12:35 |只看该作者
http://www.enhand.net/blog.php?id=262

  1. 双线用pf做策略路由和负载平衡
  2. pf.conf如下:
  3. #接内网
  4. lan_net = "192.168.0.0/24"
  5. int_if = "msk0"
  6. #接电信
  7. ext_if1 = "fxp0"
  8. #接网通
  9. ext_if2 = "fxp1"
  10. ext_gw1 = "192.168.2.248"
  11. ext_gw2 = "10.10.10.1"


  12. # nat outgoing connections on each internet interface

  13. nat on $ext_if1 from $lan_net to any -> ($ext_if1)
  14. nat on $ext_if2 from $lan_net to any -> ($ext_if2)

  15. pass in all
  16. pass out all
  17. # default deny
  18. #block in from any to any
  19. #block out from any to any

  20. #下面是策略路由
  21. #电信的DNS走电信
  22. pass in quick on $int_if route-to ($ext_if1 $ext_gw1) from any to {202.103.224.68 202.103.225.68}

  23. #WEB走电信
  24. pass in quick on $int_if route-to ($ext_if2 $ext_gw2) proto tcp from any to any port 80

  25. #下面是双线负载,抄书的
  26. # pass all outgoing packets on internal interface
  27. pass out on $int_if from any to $lan_net
  28. # pass in quick any packets destined for the gateway itself
  29. pass in quick on $int_if from $lan_net to $int_if
  30. # load balance outgoing tcp traffic from internal network.
  31. 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
  32. # load balance outgoing udp and icmp traffic from internal network
  33. 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

  34. # general "pass out" rules for external interfaces
  35. pass out on $ext_if1 proto tcp from any to any flags S/SA modulate state
  36. pass out on $ext_if1 proto { udp, icmp } from any to any keep state
  37. pass out on $ext_if2 proto tcp from any to any flags S/SA modulate state
  38. pass out on $ext_if2 proto { udp, icmp } from any to any keep state

  39. # route packets from any IPs on $ext_if1 to $ext_gw1 and the same for $ext_if2 and $ext_gw2
  40. pass out on $ext_if1 route-to ($ext_if2 $ext_gw2) from $ext_if2 to any
  41. pass out on $ext_if2 route-to ($ext_if1 $ext_gw1) from $ext_if1 to any
复制代码


http://www.abc188.com/info/html/ ... 0090513/128083.html
利用PF实现策略路由

google 查找关键字: pf 路由策略

论坛徽章:
0
3 [报告]
发表于 2009-09-22 13:59 |只看该作者
收藏起来 以备显摆时用
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP