大规模路由
拓扑
实验要求
- 某企业总公司和分公司运行 BGP 实现路由互通,另外还有办事处运行 isis。总公司和分公司之间通过两条线路相连。企业内有 A 流和 B 流两种流量,如图所示
- 按照图示配置 IP 地址,除 R7 外,所有路由配置 Loopback0 口 IP 地址用于 OSPF 的 Router-id 和 IBGP 建立邻居,地址格式为 X.X.X.X/32,X 为设备编号
- 总公司和分公司内部配置 OSPF,仅用于实现 BGP 的 TCP 可达,不允许宣告业务网段
- 办事处和总公司之间配置 RIPv2
- 适当调整链路 Cost,避免产生等价路由
- 总公司和分公司配置 BGP 实现路由互通,总公司在 AS 65001,分公司在 AS 65002,各自 AS 内部使用对等体组建立可靠的 IBGP 全连接,AS 之间使用直连接口建立 EBGP 邻居,总公司和分公司的业务网段宣告在 BGP 中
- 为了实现总公司和分公司的流量负载均衡,要求通过路由策略,使 A 流数据经过 R2 和 R4,B 流数据经过 R3 和 R5
- 在 R2 上配置 RIP 和 BGP 的双向引入,要求办事处的 A 流和 B 流都能与总公司互通,但办事处与分公司之间只有 A 流能够互通
- 不允许业务网段出现协议报文,不允许出现不相关的 RIP 协议报文
- 随着公司业务发展,后续可能会有其他分公司通过 R2 或 R3 接入总公司;不允许分公司之间互访,所以要求总公司只能对分公司发布属于本 AS 的路由
实验配置
一、基本配置(设备名,ip地址)
略
二、IGP路由协议配置(两个ospf一个isis)
略
三、总部和分部三条链路cost分别修改为10、15、30,避免产生等价路由
[R1]int g0/0
[R1-GigabitEthernet0/0]ospf cost 10
[R1-GigabitEthernet0/0]int g0/1
[R1-GigabitEthernet0/1]ospf cost 30
[R2]int g0/0
[R2-GigabitEthernet0/0]ospf cost 10
[R2-GigabitEthernet0/0]int g0/1
[R2-GigabitEthernet0/1]ospf cost 15
[R3]int g0/0
[R3-GigabitEthernet0/0]ospf cost 30
[R3-GigabitEthernet0/0]int g0/1
[R3-GigabitEthernet0/1]ospf cost 15
[R4]int g0/1
[R4-GigabitEthernet0/1]ospf cost 10
[R4-GigabitEthernet0/1]int g0/2
[R4-GigabitEthernet0/2]ospf cost 15
[R5]int g0/0
[R5-GigabitEthernet0/0]ospf cost 10
[R5-GigabitEthernet0/0]int g0/2
[R5-GigabitEthernet0/2]ospf cost 30
[R6]int g0/1
[R6-GigabitEthernet0/1]ospf cost 15
[R6-GigabitEthernet0/1]int g0/0
[R6-GigabitEthernet0/0]ospf cost 30
四、总部建立IBGP全连接
R1
[R1]bgp 65001
[R1-bgp-default]router-id 1.1.1.1
[R1-bgp-default]peer 2.2.2.2 as-number 65001
[R1-bgp-default]peer 3.3.3.3 as-number 65001
[R1-bgp-default]peer 3.3.3.3 connect-interface LoopBack 0
[R1-bgp-default]peer 2.2.2.2 connect-interface LoopBack 0
[R1-bgp-default]address-family ipv4
[R1-bgp-default-ipv4]peer 2.2.2.2 enable
[R1-bgp-default-ipv4]peer 3.3.3.3 enable
R2
[R2-GigabitEthernet0/1]bgp 65001
[R2-bgp-default]router-id 2.2.2.2
[R2-bgp-default]peer 1.1.1.1 as-number 65001
[R2-bgp-default]peer 1.1.1.1 connect-interface l0
[R2-bgp-default]peer 3.3.3.3 as-number 65001
[R2-bgp-default]peer 3.3.3.3 connect-interface l0
[R2-bgp-default]address-family ipv4
[R2-bgp-default-ipv4]peer 1.1.1.1 enable
[R2-bgp-default-ipv4]peer 3.3.3.3 enable
[R2-bgp-default-ipv4]peer 1.1.1.1 next-hop-local
[R2-bgp-default-ipv4]peer 3.3.3.3 next-hop-local
R3
[R3]bgp 65001
[R3-bgp-default]router-id 3.3.3.3
[R3-bgp-default]peer 1.1.1.1 as-number 65001
[R3-bgp-default]peer 2.2.2.2 as-number 65001
[R3-bgp-default]peer 1.1.1.1 connect-interface l0
[R3-bgp-default]peer 2.2.2.2 connect-interface l0
[R3-bgp-default]address-family ipv4
[R3-bgp-default-ipv4]peer 1.1.1.1 enable
[R3-bgp-default-ipv4]peer 2.2.2.2 enable
[R3-bgp-default-ipv4]peer 1.1.1.1 next-hop-local
[R3-bgp-default-ipv4]peer 2.2.2.2 next-hop-local
五、分部建立IBGP全连接
略(类似于步骤四)
六、建立EBGP对等体R2和R4、R3和R5
[R2-bgp-default]peer 24.1.1.4 as-number 65002
[R2-bgp-default]address-family ipv4
[R2-bgp-default-ipv4]peer 24.1.1.4 enable
[R4-bgp-default]peer 24.1.1.2 as-number 65001
[R4-bgp-default]address-family ipv4
[R4-bgp-default-ipv4]peer 24.1.1.2 enable
[R3-bgp-default]peer 35.1.1.5 as-number 65002
[R3-bgp-default]address-family ipv4
[R3-bgp-default-ipv4]peer 35.1.1.5 enable
[R5-bgp-default]peer 35.1.1.3 as-number 65001
[R5-bgp-default]address-family ipv4
[R5-bgp-default-ipv4]peer 35.1.1.3 enable
七、将总部和发布的业务网段宣告在BGP中
[R1-bgp-default-ipv4]net 192.168.0.0 24
[R1-bgp-default-ipv4]net 172.16.0.0 24
[R6-bgp-default-ipv4]network 192.168.1.0 24
[R6-bgp-default-ipv4]net 172.16.1.0 24
检测连通性
八、要求通过路由策略,使 A 流数据经过 R2 和 R4,B 流数据经过 R3 和 R5
[R2]acl basic 2000
[R2-acl-ipv4-basic-2000]rule permit source 172.16.1.0 0.0.0.255
[R2]route-policy b permit node 10
[R2-route-policy-b-10]if ip a acl 2000
[R2-route-policy-b-10]apply as-path 65003 65002
[R2]route-policy b permit node 20
[R2-route-policy-b-10]bgp 65001
[R2-bgp-default]address-family ipv4
[R2-bgp-default-ipv4]peer 24.1.1.4 route-policy b import
[R3]acl basic 2000
[R3-acl-ipv4-basic-2000]rule permit source 192.168.1.0 0.0.0.255
[R3]route-policy a permit node 10
[R3-route-policy-a-10]if ip address acl 2000
[R3-route-policy-a-10]apply as-path 65002
[R3]route-policy a permit node
[R3-route-policy-a-10]bgp 65001
[R3-bgp-default]address-family ipv4
[R3-bgp-default-ipv4]peer 35.1.1.5 route-policy a import
[R4]ip prefix-list b permit 172.16.0.0 24
[R4]route-policy b permit node 10
[R4-route-policy-b-10]if ip a prefix-list b
[R4-route-policy-b-10]apply as-path 65001
[R4]route-policy b permit node 20
[R4-route-policy-b-10]bgp 65002
[R4-bgp-default]address-family ipv4
[R4-bgp-default-ipv4]peer 24.1.1.2 route-policy b import
[R5]ip prefix-list a permit 192.168.0.0 24
[R5]route-policy a permit node 10
[R5-route-policy-a-10]if ip a prefix-list a
[R5-route-policy-a-10]apply as-path 65001
[R5]route-policy a permit node 20
[R5-route-policy-a-10]bgp 65002
[R5-bgp-default]address-family ipv4
[R5-bgp-default-ipv4]peer 35.1.1.3 route-policy a import
九、在 R2 上配置 RIP 和 BGP 的双向引入,要求办事处的 A 流和 B 流都能与总公司互通,但办事处与分公司之间只有 A 流能够互通
[R2]acl basic 2001
[R2-acl-ipv4-basic-2001]rule permit source 172.16.1.0 0.0.0.255
[R2]route-policy b2s deny node 10
[R2-route-policy-b2s-10]if-match ip a acl 2001
[R2]route-policy b2s permit node 20
[R2-isis-1-ipv4]import-route bgp allow-ibgp route-policy b2s
[R2-bgp-default-ipv4]import-route isis
十、随着公司业务发展,后续可能会有其他分公司通过 R2 或 R3 接入总公司;不允许分公司之间互访,所以要求总公司只能对分公司发布属于本 AS 的路由
[R2]ip as-path 1 permit ^$
[R2]ip as-path 1 deny .*
[R2]bgp 65001
[R2-bgp-default]address-family ipv4
[R2-bgp-default-ipv4]peer 24.1.1.4 as-path-acl 1 export
[R3]ip as-path 1 permit ^$
[R3]ip as-path 1 deny .*
[R3]bgp 65001
[R3-bgp-default]ad
[R3-bgp-default]address-family ipv4
[R3-bgp-default-ipv4]peer 35.1.1.5 as-path-acl 1 export