今天继续H3C比赛的复习,今天因为比较忙,只复习了OSPF和BGP,现在先对BGP进行总结
先上一个比较简单的配置实例,是在配置手册上面贴的
组网图
- 配置步骤
- # 配置 SecPathA:
- [H3C] bgp 1001
- [H3C-bgp] confederation id 100
- [H3C-bgp] confederation peer-as 1002 1003
- [H3C-bgp] group confed1002 external
- [H3C-bgp] peer confed1002 as-number 1002
- [H3C-bgp] group confed1003 external
- [H3C-bgp] peer confed1003 as-number 1003
- [H3C-bgp] peer 172.68.10.2 group confed1002
- [H3C-bgp] peer 172.68.10.3 group confed1003
- # 配置 SecPathB:
- [H3C] bgp 1002
- [H3C-bgp] confederation id 100
- [H3C-bgp] confederation peer-as 1001 1003
- [H3C-bgp] group confed1001 external
- [H3C-bgp] peer confed1001 as-number 1001
- [H3C-bgp] group confed1003 external
- [H3C-bgp] peer confed1003 as-number 1003
- [H3C-bgp] peer 172.68.10.1 group confed1001
- [H3C-bgp] peer 172.68.10.3 group confed1003
- # 配置 SecPathC:
- [H3C] bgp 1003
- [H3C-bgp] confederation id 100
- [H3C-bgp] confederation peer-as 1001 1002
- [H3C-bgp] group confed1001 external
- [H3C-bgp] peer confed1001 as-number 1001
- [H3C-bgp] group confed1002 external
- [H3C-bgp] peer confed1002 as-number 1002
- [H3C-bgp] peer 172.68.10.1 group confed1001
- [H3C-bgp] peer 172.68.10.2 group confed1002
- [H3C-bgp] group ebgp200 external
- [H3C-bgp] peer 156.10.1.2 group ebgp200 as-number 200
- [H3C-bgp] group ibgp1003 internal
- [H3C-bgp] peer 172.68.1.2 group ibgp1003
这里说一下自己对于路由协议的一些肤浅的认识,首先路由协议都是适合使用在某些特定的网络环境里面的,而在特定的环境下又希望可以尽可能的提高效率,因此做法有大概两种,一种是减少网络更新时节点的信息传递次数,避免环路的发生;另一种是通过分区域,把大的区域分成一个个相对小的区域,通称自治区域。这样对于自治区域之间只需要把请求发送给发言人,发言人处理自治区域里面的信息,而区域里面通常又是一个局域网里面可以使用RIP和OSPF,OSPF也是通过把大区域划分成为小区域进行更好地管理。
配置步骤
- # 配置 SecPathA:
- [H3C] interface ethernet 2/0/0
- [H3C-Ethernet2/0/0] ip address 192.1.1.1 255.255.255.0
- [H3C-Ethernet2/0/0] interface ethernet 1/0/0
- [H3C-Ethernet1/0/0] ip address 193.1.1.1 255.255.255.0
- [H3C-Ethernet1/0/0] quit
- [H3C] bgp 100
- [H3C-bgp] network 1.0.0.0
- [H3C-bgp] group ex192 external
- [H3C-bgp] peer 192.1.1.2 group ex192 as-number 200
- [H3C-bgp] group ex193 external
- [H3C-bgp] peer 193.1.1.2 group ex193 as-number 200
- [H3C-bgp] quit
- # 增加访问列表到 SecPathA 上,允许网络 1.0.0.0
- [H3C] acl number 2001
- [H3C-acl-basic-2001] rule permit source 1.0.0.0 0.255.255.255
- # 定义两个 Route-policy,一个名为 apply_med_50,另一个名为 apply_med_100,
- 第一个 Route-policy 为网络 1.0.0.0 设置的 MED 属性为 50,第二个 Route-policy
- 设置的 MED 属性为 100。
- [H3C] route-policy apply_med_50 permit node 10
- [H3C-route-policy] if-match acl 2001
- [H3C-route-policy] apply cost 50
- [H3C-route-policy] quit
- [H3C] route-policy apply_med_100 permit node 10
- [H3C-route-policy] if-match acl 2001
- [H3C-route-policy] apply cost 100
- [H3C-route-policy] quit
- # 应用 apply_med_50 到邻居 SecPathC(193.1.1.2)出口路由更新上,应用
- apply_med_100 到邻居 SecPathB(192.1.1.2)的出口路由更新上。
- [H3C] bgp 100
- [H3C-bgp] peer ex193 route-policy apply_med_50 export
- [H3C-bgp] peer ex192 route-policy apply_med_100 export
- # 配置 SecPathB:
- [H3C] interface ethernet 2/0/0
- [H3C-Ethernet2/0/0] ip address 192.1.1.2 255.255.255.0
- [H3C-Ethernet2/0/0] interface ethernet 1/0/0
- [H3C-Ethernet1/0/0] ip address 194.1.1.2 255.255.255.0
- [H3C-Ethernet1/0/0] quit
- [H3C] ospf
- [H3C-ospf-1] area 0
- [H3C-ospf-1-area-0.0.0.0] network 194.1.1.0 0.0.0.255
- [H3C-ospf-1-area-0.0.0.0] network 192.1.1.0 0.0.0.255
- [H3C] bgp 200
- [H3C-bgp] undo synchronization
- [H3C-bgp] group ex external
- [H3C-bgp] peer 192.1.1.1 group ex as-number 100
- [H3C-bgp] group in internal
- [H3C-bgp] peer 194.1.1.1 group in
- # 配置 SecPathC:
- [H3C] interface ethernet 1/0/0
- [H3C-Ethernet1/0/0] ip address 193.1.1.2 255.255.255.0
- [H3C-Ethernet1/0/0] interface ethernet 2/0/0
- [H3C-Ethernet2/0/0] ip address 195.1.1.2 255.255.255.0
- [H3C-Ethernet2/0/0] quit
- [H3C] ospf
- [H3C-ospf-1] area 0
- [H3C-ospf-1-area-0.0.0.0] network 193.1.1.0 0.0.0.255
- [H3C-ospf-1-area-0.0.0.0] network 195.1.1.0 0.0.0.255
- [H3C] bgp 200
- [H3C-bgp] group ex external
- [H3C-bgp] peer 193.1.1.1 group ex as-number 100
- [H3C-bgp] group in internal
- [H3C-bgp] peer 195.1.1.1 group in
- # 配置 SecPathD:
- [H3C] interface ethernet 1/0/0
- [H3C-Ethernet1/0/0] ip address 194.1.1.1 255.255.255.0
- [H3C-Ethernet1/0/0] interface ethernet 2/0/0
- [H3C-Ethernet2/0/0] ip address 195.1.1.1 255.255.255.0
- [H3C-Ethernet2/0/0] quit
- [H3C] ospf
- [H3C-ospf-1] area 0
- [H3C-ospf-1-area-0.0.0.0] network 194.1.1.0 0.0.0.255
- [H3C-osp-1f-area-0.0.0.0] network 195.1.1.0 0.0.0.255
- [H3C-ospf-1-area-0.0.0.0] network 4.0.0.0 0.255.255.255
- [H3C] bgp 200
- [H3C-bgp] group ex external
- [H3C-bgp] peer ex as-number 200
- [H3C-bgp] peer 195.1.1.2 group ex
- [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 上配置
本地优先级如下:
- # 在 SecPathC 上加上访问列表 2001,允许网络 1.0.0.0
- [H3C] acl number 2001
- [H3C-acl-basic-2001] rule permit source 1.0.0.0 0.255.255.255
- # 定义名为 localpref 的路由策略,设置匹配 access list 2001(访问列表 2001)的
- 路由的本地优先级为 200,不匹配的为 100。
- [H3C] route-policy localpref permit node 10
- [H3C-route-policy] if-match acl 2001
- [H3C-route-policy] apply local-preference 200
- [H3C-route-policy] quit
- [H3C] route-policy localpref permit node 20
- [H3C-route-policy] apply local-preference 100
- [H3C] quit
- # 应用此路由策略到来自 BGP 邻居 193.1.1.1(SecPathA)上。
- [H3C] bgp 200
- [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。
转载于:https://blog.51cto.com/chailink/834780