1.组网需求  

  所有路由器都运行BGP协议。Switch A与Switch B和Switch C之间运行EBGP;Switch D与Switch B和Switch C之间运行IBGP。

  AS 200中运行OSPF协议。

  配置路由策略,使得Switch D优选从Switch C学到的1.0.0.0/8路由

    

 2.配置步骤

  1)配置各接口的IP地址(略)

  2)配置Switch B、Switch C和Switch D之间运行OSPF协议

# 配置Switch B。
[SwitchB] ospf
[SwitchB-ospf] area 0
[SwitchB-ospf-1-area-0.0.0.0] network 192.1.1.0 0.0.0.255
[SwitchB-ospf-1-area-0.0.0.0] network 194.1.1.0 0.0.0.255
# 配置Switch C。
[SwitchC] ospf
[SwitchC-ospf] area 0
[SwitchC-ospf-1-area-0.0.0.0] network 193.1.1.0 0.0.0.255
[SwitchC-ospf-1-area-0.0.0.0] network 195.1.1.0 0.0.0.255
# 配置Switch D。
[SwitchD] ospf
[SwitchD-ospf] area 0
[SwitchD-ospf-1-area-0.0.0.0] network 194.1.1.0 0.0.0.255
[SwitchD-ospf-1-area-0.0.0.0] network 195.1.1.0 0.0.0.255

  3)配置BGP连接

# 配置Switch A。
[SwitchA] bgp 100
[SwitchA-bgp-default] peer 192.1.1.2 as-number 200
[SwitchA-bgp-default] peer 193.1.1.2 as-number 200
[SwitchA-bgp-default] address-family ipv4 unicast
[SwitchA-bgp-default-ipv4] peer 192.1.1.2 enable
[SwitchA-bgp-default-ipv4] peer 193.1.1.2 enable
[SwitchA-bgp-default-ipv4] network 1.0.0.0 8   # 将1.0.0.0/8网段通告到Switch A的BGP路由表中。
# 配置Switch B。
[SwitchB] bgp 200
[SwitchB-bgp-default] peer 192.1.1.1 as-number 100
[SwitchB-bgp-default] peer 194.1.1.1 as-number 200
[SwitchB-bgp-default] address-family ipv4 unicast
[SwitchB-bgp-default-ipv4] peer 192.1.1.1 enable
[SwitchB-bgp-default-ipv4] peer 194.1.1.1 enable
# 配置Switch C。
[SwitchC] bgp 200
[SwitchC-bgp-default] peer 193.1.1.1 as-number 100
[SwitchC-bgp-default] peer 195.1.1.1 as-number 200
[SwitchC-bgp-default] address-family ipv4 unicast
[SwitchC-bgp-default-ipv4] peer 193.1.1.1 enable
[SwitchC-bgp-default-ipv4] peer 195.1.1.1 enable
# 配置Switch D。
[SwitchD] bgp 200
[SwitchD-bgp-default] peer 194.1.1.2 as-number 200
[SwitchD-bgp-default] peer 195.1.1.2 as-number 200
[SwitchD-bgp-default] address-family ipv4 unicast
[SwitchD-bgp-default-ipv4] peer 194.1.1.2 enable
[SwitchD-bgp-default-ipv4] peer 195.1.1.2 enable

  4)通过配置本地优先级,使得Switch D优选从Switch C学到的路由。

# 在Switch C上定义编号为2000的IPv4基本ACL,允许1.0.0.0/8路由通过。
[SwitchC] acl basic 2000
[SwitchC-acl-ipv4-basic-2000] rule permit source 1.0.0.0 0.255.255.255
# 在Switch C上定义名为localpref的Route-policy,设置路由1.0.0.0/8的本地优先级为200(缺省的本地优先级为100)。
[SwitchC] route-policy localpref permit node 10
[SwitchC-route-policy-localpref-10] if-match ip address acl 2000
[SwitchC-route-policy-localpref-10] apply local-preference 200
# 为从BGP对等体193.1.1.1的路由应用名为localpref的Route-policy。
[SwitchC] bgp 200
[SwitchC-bgp-default] address-family ipv4 unicast
[SwitchC-bgp-default-ipv4] peer 193.1.1.1 route-policy localpref import

  5)# 查看Switch D的BGP路由表。

[SwitchD] display bgp routing-table ipv4
 Total number of routes: 2
 BGP local router ID is 195.1.1.1
 Status codes: * - valid, > - best, d - dampened, h - history,
               s - suppressed, S - stale, i - internal, e - external
               a – additional-path
       Origin: i - IGP, e - EGP, ? - incomplete
     Network            NextHop         MED        LocPrf     PrefVal Path/Ogn
* >i 1.0.0.0            193.1.1.1                  200        0       100i
*  i                    192.1.1.1                  100        0       100i  
可以看到,Switch D从Switch C学到1.0.0.0/8的路由是最优的。

 

posted on 2022-01-13 14:53  星痕1216  阅读(460)  评论(0编辑  收藏  举报