实验拓扑:
要求:
BGP动态路由实验:
4台路由器基础名称,接口IP均配置
(1).4台PC分别在4个不同网段:
(2).4台路由器loopback0地址分别是:
(3).路由器之间中继链路使用接口地址为:192.168.0.0/16,已经有基础配置。
组网要求使用BGP动态路由方式:
实验配置步骤:
R1:
#
interface GigabitEthernet0/0/0
description R1-R3-GE0/0/0
ip address 192.168.13.1 255.255.255.252
#
interface GigabitEthernet0/0/1
description R1-R2
ip address 192.168.12.1 255.255.255.252
#
interface GigabitEthernet1/0/0
description R1-R3-GE1/0/0
ip address 192.168.13.5 255.255.255.252
#
interface GigabitEthernet5/0/0
description R1-PC1
ip address 10.1.1.1 255.255.255.0
#
interface LoopBack0
ip address 1.1.1.1 255.255.255.255
#
R2:
#
interface GigabitEthernet0/0/1
description R2-R1
ip address 192.168.12.2 255.255.255.252
#
interface GigabitEthernet5/0/0
description R2-PC2
ip address 10.1.2.1 255.255.255.0
#
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
#
R3:
#
interface GigabitEthernet0/0/0
description R3-R1-GE0/0/0
ip address 192.168.13.2 255.255.255.252
#
interface GigabitEthernet0/0/1
description R3-R4-GE0/0/1
ip address 192.168.34.1 255.255.255.252
#
interface GigabitEthernet1/0/0
description R3-R1-GE1/0/0
ip address 192.168.13.6 255.255.255.252
#
interface GigabitEthernet5/0/0
description R3-PC3
ip address 10.2.3.2 255.255.255.128
#
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
#
R4:
#
interface GigabitEthernet0/0/1
description R4-R3-GE0/0/1
ip address 192.168.34.2 255.255.255.252
#
interface GigabitEthernet5/0/0
description R4-PC4
ip address 10.2.4.1 255.255.255.128
#
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
#
配置完成后测试地址直连地址连通性:此处不一一测试。
AS100内运行OSPF,AS200内采用静态路由保证R3、R4的loopback 0 地址互通。具体配置如下: AS100内: R1:
#
ospf 1
area 0.0.0.0
network 1.1.1.1 0.0.0.0
network 192.168.12.0 0.0.0.255
#
R2:
#
ospf 1
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 192.168.12.0 0.0.0.255
area 0.0.0.12
#
AS200内: R3:
#
ip route-static 4.4.4.4 255.255.255.255 192.168.34.2
#
R4:
#
ip route-static 3.3.3.3 255.255.255.255 192.168.34.1
#
R1:
#
bgp 100
peer 2.2.2.2 as-number 100
peer 2.2.2.2 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 1.1.1.1 255.255.255.255
network 10.1.1.0 255.255.255.0
peer 2.2.2.2 enable
#
R2:
bgp 100
peer 1.1.1.1 as-number 100
peer 1.1.1.1 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 2.2.2.2 255.255.255.255
network 10.1.2.0 255.255.255.0
peer 1.1.1.1 enable
#
R3:
#
bgp 200
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
aggregate 10.2.0.0 255.255.0.0 detail-suppressed
network 3.3.3.3 255.255.255.255
network 10.2.3.0 255.255.255.128
peer 4.4.4.4 enable
peer 4.4.4.4 default-route-advertise
#
R4:
#
bgp 200
peer 3.3.3.3 as-number 200
peer 3.3.3.3 connect-interface LoopBack0
#
ipv4-family unicast
undo synchronization
network 4.0.0.0
network 4.4.4.4 255.255.255.255
network 10.2.4.0 255.255.255.128
peer 3.3.3.3 enable
#
注意:BGP为保证路由下一跳的可达性,需要将IGP路由与EGP路由同步。故,需在R1,R3上将IGP协议路由引入。 R1:
#
bgp 100
import-route direct
import-route static
import-route ospf 1
#
R3:
#
bgp 200
import-route direct
import-route static
#
此处采用loopback口进行EBGP邻居的搭建,也可用直连口进行EBGP邻居建立,直连口建立邻居关系更简单。具体配置如下: R1:
#
ip route-static 3.3.3.3 255.255.255.255 192.168.13.2
ip route-static 3.3.3.3 255.255.255.255 192.168.13.6 #保证路由的可达性,BGP为TCP协议,需三层可达才能建立BGP邻居关系。
#
bgp 100
peer 3.3.3.3 as-number 200
peer 3.3.3.3 ebgp-max-hop 2 #EBGP邻居建立是,默认TTL值为1,利用loopback口建立邻居关系是由于loopback口之间不是直连,故需要改变EBGP邻居的多跳可达属性。
peer 3.3.3.3 connect-interface LoopBack0
#
R3:
#
ip route-static 1.1.1.1 255.255.255.255 192.168.13.1
ip route-static 1.1.1.1 255.255.255.255 192.168.13.5
#
bgp 200
peer 1.1.1.1 as-number 100
peer 1.1.1.1 ebgp-max-hop 2
peer 1.1.1.1 connect-interface LoopBack0
ipv4-family unicast
undo synchronization
aggregate 10.2.0.0 255.255.0.0 detail-suppressed
network 3.3.3.3 255.255.255.255
network 10.2.3.0 255.255.255.128
peer 1.1.1.1 enable
peer 4.4.4.4 default-route-advertise 向R4发布默认路由
#
#
bgp 200
aggregate 10.2.0.0 255.255.0.0 detail-suppressed
#
验证:在R1上查看是否有10.2.3.0或者10.2.4.0网段
R2:
#
ip ip-prefix PC2 index 10 deny 10.2.0.0 16
ip ip-prefix PC2 index 20 permit 0.0.0.0 0 less-equal 32
#
bgp 100
peer 1.1.1.1 ip-prefix PC2 import
#
R1:
R2:
R3:
R4:
PC2:
PC1:
PC3:
PC4:
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有