今天继续H3C比赛的复习,今天因为比较忙,只复习了OSPF和BGP,现在先对BGP进行总结

先上一个比较简单的配置实例,是在配置手册上面贴的

组网图

 

 
  
  1.  配置步骤  
  2. # 配置 SecPathA:  
  3. [H3C] bgp 1001  
  4. [H3C-bgp] confederation id 100  
  5. [H3C-bgp] confederation peer-as 1002 1003  
  6. [H3C-bgp] group confed1002 external  
  7. [H3C-bgp] peer confed1002 as-number 1002  
  8. [H3C-bgp] group confed1003 external  
  9. [H3C-bgp] peer confed1003 as-number 1003  
  10. [H3C-bgp] peer 172.68.10.2 group confed1002   
  11. [H3C-bgp] peer 172.68.10.3 group confed1003   
  12. # 配置 SecPathB:  
  13. [H3C] bgp 1002  
  14. [H3C-bgp] confederation id 100  
  15. [H3C-bgp] confederation peer-as 1001 1003  
  16. [H3C-bgp] group confed1001 external  
  17. [H3C-bgp] peer confed1001 as-number 1001  
  18. [H3C-bgp] group confed1003 external  
  19. [H3C-bgp] peer confed1003 as-number 1003  
  20. [H3C-bgp] peer 172.68.10.1 group confed1001  
  21. [H3C-bgp] peer 172.68.10.3 group confed1003  
  22. # 配置 SecPathC:  
  23. [H3C] bgp 1003  
  24. [H3C-bgp] confederation id 100  
  25. [H3C-bgp] confederation peer-as 1001 1002  
  26. [H3C-bgp] group confed1001 external  
  27. [H3C-bgp] peer confed1001 as-number 1001  
  28. [H3C-bgp] group confed1002 external  
  29. [H3C-bgp] peer confed1002 as-number 1002  
  30. [H3C-bgp] peer 172.68.10.1 group confed1001  
  31. [H3C-bgp] peer 172.68.10.2 group confed1002  
  32. [H3C-bgp] group ebgp200 external  
  33. [H3C-bgp] peer 156.10.1.2 group ebgp200 as-number 200  
  34. [H3C-bgp] group ibgp1003 internal  
  35. [H3C-bgp] peer 172.68.1.2 group ibgp1003 

这里说一下自己对于路由协议的一些肤浅的认识,首先路由协议都是适合使用在某些特定的网络环境里面的,而在特定的环境下又希望可以尽可能的提高效率,因此做法有大概两种,一种是减少网络更新时节点的信息传递次数,避免环路的发生;另一种是通过分区域,把大的区域分成一个个相对小的区域,通称自治区域。这样对于自治区域之间只需要把请求发送给发言人,发言人处理自治区域里面的信息,而区域里面通常又是一个局域网里面可以使用RIP和OSPF,OSPF也是通过把大区域划分成为小区域进行更好地管理。

BGP配置的具体步骤可以分为:
1、为每个相邻的自治区域起一个名字,确定是external或者in属性;
2、把具体区域的发言人的ip设置在对应的区域名字的peer上;
3、按照需要增加过滤的策略
 
 
下面贴一个配置有基于acl过滤策略的BGP设置(也是贴手册的内容)
 

 

配置步骤 

 

 
  
  1. # 配置 SecPathA:  
  2. [H3C] interface ethernet 2/0/0  
  3. [H3C-Ethernet2/0/0] ip address 192.1.1.1 255.255.255.0  
  4. [H3C-Ethernet2/0/0] interface ethernet 1/0/0  
  5. [H3C-Ethernet1/0/0] ip address 193.1.1.1 255.255.255.0  
  6. [H3C-Ethernet1/0/0] quit  
  7. [H3C] bgp 100  
  8. [H3C-bgp] network 1.0.0.0  
  9. [H3C-bgp] group ex192 external  
  10. [H3C-bgp] peer 192.1.1.2 group ex192 as-number 200  
  11. [H3C-bgp] group ex193 external  
  12. [H3C-bgp] peer 193.1.1.2 group ex193 as-number 200  
  13. [H3C-bgp] quit  

 

 
 
  
  1. # 增加访问列表到 SecPathA 上,允许网络 1.0.0.0  
  2. [H3C] acl number 2001  
  3. [H3C-acl-basic-2001] rule permit source 1.0.0.0 0.255.255.255  
  4. # 定义两个 Route-policy,一个名为 apply_med_50,另一个名为 apply_med_100, 
  5. 第一个 Route-policy 为网络 1.0.0.0 设置的 MED 属性为 50,第二个 Route-policy 
  6. 设置的 MED 属性为 100。  
  7. [H3C] route-policy apply_med_50 permit node 10  
  8. [H3C-route-policy] if-match acl 2001  
  9. [H3C-route-policy] apply cost 50  
  10. [H3C-route-policy] quit  
  11. [H3C] route-policy apply_med_100 permit node 10  
  12. [H3C-route-policy] if-match acl 2001  
  13. [H3C-route-policy] apply cost 100  
  14. [H3C-route-policy] quit  
  15. #  应用 apply_med_50  到邻居 SecPathC(193.1.1.2)出口路由更新上,应用 
  16. apply_med_100 到邻居 SecPathB(192.1.1.2)的出口路由更新上。  
  17. [H3C] bgp 100  
  18. [H3C-bgp] peer ex193 route-policy apply_med_50 export  
  19. [H3C-bgp] peer ex192 route-policy apply_med_100 export  
  20.  
  21. # 配置 SecPathB:  
  22. [H3C] interface ethernet 2/0/0  
  23. [H3C-Ethernet2/0/0] ip address 192.1.1.2 255.255.255.0  
  24. [H3C-Ethernet2/0/0] interface ethernet 1/0/0  
  25. [H3C-Ethernet1/0/0] ip address 194.1.1.2 255.255.255.0  
  26. [H3C-Ethernet1/0/0] quit  
  27. [H3C] ospf  
  28. [H3C-ospf-1] area 0  
  29. [H3C-ospf-1-area-0.0.0.0] network 194.1.1.0 0.0.0.255   
  30. [H3C-ospf-1-area-0.0.0.0] network 192.1.1.0 0.0.0.255  
  31. [H3C] bgp 200  
  32. [H3C-bgp] undo synchronization  
  33. [H3C-bgp] group ex external  
  34. [H3C-bgp] peer 192.1.1.1 group ex as-number 100  
  35. [H3C-bgp] group in internal   
  36. [H3C-bgp] peer 194.1.1.1 group in  
  37.  
  38. # 配置 SecPathC:  
  39. [H3C] interface ethernet 1/0/0  
  40. [H3C-Ethernet1/0/0] ip address 193.1.1.2 255.255.255.0  
  41. [H3C-Ethernet1/0/0] interface ethernet 2/0/0  
  42. [H3C-Ethernet2/0/0] ip address 195.1.1.2 255.255.255.0  
  43. [H3C-Ethernet2/0/0] quit  
  44. [H3C] ospf  
  45. [H3C-ospf-1] area 0  
  46. [H3C-ospf-1-area-0.0.0.0] network 193.1.1.0 0.0.0.255  
  47. [H3C-ospf-1-area-0.0.0.0] network 195.1.1.0 0.0.0.255  
  48. [H3C] bgp 200  
  49. [H3C-bgp] group ex external  
  50. [H3C-bgp] peer 193.1.1.1 group ex as-number 100  
  51. [H3C-bgp] group in internal  
  52. [H3C-bgp] peer 195.1.1.1 group in  
  53.  
  54. # 配置 SecPathD:  
  55. [H3C] interface ethernet 1/0/0  
  56. [H3C-Ethernet1/0/0] ip address 194.1.1.1 255.255.255.0  
  57. [H3C-Ethernet1/0/0] interface ethernet 2/0/0  
  58. [H3C-Ethernet2/0/0] ip address 195.1.1.1 255.255.255.0  
  59. [H3C-Ethernet2/0/0] quit  
  60. [H3C] ospf  
  61. [H3C-ospf-1] area 0  
  62. [H3C-ospf-1-area-0.0.0.0] network 194.1.1.0 0.0.0.255  
  63. [H3C-osp-1f-area-0.0.0.0] network 195.1.1.0 0.0.0.255  
  64. [H3C-ospf-1-area-0.0.0.0] network 4.0.0.0 0.255.255.255  
  65. [H3C] bgp 200  
  66. [H3C-bgp] group ex external  
  67. [H3C-bgp] peer ex as-number 200  
  68. [H3C-bgp] peer 195.1.1.2 group ex  
  69. [H3C-bgp] peer 194.1.1.2 group ex  

为使配置生效,需要使用 reset bgp all 命令复位所有的 BGP 邻居。 

通过上述配置后,由于 SecPathC 学到的路由 1.0.0.0 的 MED 属性比 SecPathB 

到的更小,SecPathD 优选来自 SecPathC 的路由 1.0.0.0。 

如果在配置 SecPathA 时,不配置 SecPathA 的 MED 属性,而在 SecPathC 上配置

本地优先级如下: 

 

 
  
  1. # 在 SecPathC 上加上访问列表 2001,允许网络 1.0.0.0  
  2. [H3C] acl number 2001  
  3. [H3C-acl-basic-2001] rule permit source 1.0.0.0 0.255.255.255  
  4. # 定义名为 localpref 的路由策略,设置匹配 access list 2001(访问列表 2001)的 
  5. 路由的本地优先级为 200,不匹配的为 100。  
  6. [H3C] route-policy localpref permit node 10  
  7. [H3C-route-policy] if-match acl 2001  
  8. [H3C-route-policy] apply local-preference 200  
  9. [H3C-route-policy] quit  
  10. [H3C] route-policy localpref permit node 20  
  11. [H3C-route-policy] apply local-preference 100  
  12. [H3C] quit  
  13. # 应用此路由策略到来自 BGP 邻居 193.1.1.1(SecPathA)上。  
  14. [H3C] bgp 200  
  15. [H3C-bgp] peer 193.1.1.1 route-policy localpref import  

此时,由于 SecPathC 学到的路由 1.0.0.0 的 Local  preference 属性值为 200,比

SecPathB 学到的路由1.0.0.0 Local preference 属性值(SecPathB 没有配置Local 

preference 属性,默认为 100)更大,SecPathD 依然优选来自 SecPathC 的路由

1.0.0.0