#lab BGP1# 基本配置
实验拓扑:
配置:
R1-
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface Serial1/0
ip address 12.1.1.1 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 13.1.1.1 255.255.255.0
serial restart-delay 0
!
router ospf 110 //AS内部使用OSPF路由协议
router-id 1.1.1.1
log-adjacency-changes
network 1.1.1.0 0.0.0.255 area 0
network 12.1.1.0 0.0.0.255 area 0
network 13.1.1.0 0.0.0.255 area 0
!
router bgp 1
no synchronization
bgp router-id 1.1.1.1 //BGP的routerID
bgp log-neighbor-changes
neighbor J peer-group //BGP需要指邻居
neighbor J remote-as 1 //邻居的AS号
neighbor J update-source Loopback0 //更新源,如果不指定默认是包发送端口的IP
neighbor 2.2.2.2 peer-group J //调用上述建邻居模板
neighbor 3.3.3.3 peer-group J //调用模板
no auto-summary
!
R2-
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Serial1/0
ip address 12.1.1.2 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 24.1.1.2 255.255.255.0
serial restart-delay 0
!
router ospf 110
router-id 2.2.2.2
log-adjacency-changes
network 2.2.2.0 0.0.0.255 area 0
network 12.1.1.0 0.0.0.255 area 0
!
router bgp 1
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self //保证下一跳可达,主要做在AS边界路由器上
neighbor 3.3.3.3 remote-as 1
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 24.1.1.4 remote-as 4 //EBGP邻居,直连接口建邻居,如果是用环回口,必须修改多跳和update source
no auto-summary
!
R3-
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface Serial1/0
ip address 35.1.1.3 255.255.255.0
serial restart-delay 0
!
interface Serial1/1
ip address 13.1.1.3 255.255.255.0
serial restart-delay 0
!
router ospf 110
router-id 3.3.3.3
log-adjacency-changes
network 3.3.3.0 0.0.0.255 area 0
network 13.1.1.0 0.0.0.255 area 0
!
router bgp 1
no synchronization
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source Loopback0
neighbor 1.1.1.1 next-hop-self
neighbor 2.2.2.2 remote-as 1
neighbor 2.2.2.2 update-source Loopback0
neighbor 2.2.2.2 next-hop-self
neighbor 5.5.5.5 remote-as 5 //EBGP邻居
neighbor 5.5.5.5 ebgp-multihop 2 //修改多跳
neighbor 5.5.5.5 update-source Loopback0 //用环回口建邻居
no auto-summary
!
ip route 5.5.5.5 255.255.255.255 Serial1/0 //环回口建邻居,必须保证有路由
R4-
interface Loopback0
ip address 4.4.4.4 255.255.255.0
!
interface Serial1/1
ip address 24.1.1.4 255.255.255.0
serial restart-delay 0
!
router bgp 4
no synchronization
bgp router-id 4.4.4.4
bgp log-neighbor-changes
network 4.4.4.0 mask 255.255.255.0 //通告路由
neighbor 24.1.1.2 remote-as 1
no auto-summary
!
R5-
interface Loopback0
ip address 5.5.5.5 255.255.255.0
!
interface Serial1/0
ip address 35.1.1.5 255.255.255.0
serial restart-delay 0
!
router bgp 5
no synchronization
bgp log-neighbor-changes
network 5.5.5.0 mask 255.255.255.0 //通告路由
neighbor 3.3.3.3 remote-as 1
neighbor 3.3.3.3 ebgp-multihop 2
neighbor 3.3.3.3 update-source Loopback0
no auto-summary
!
ip route 3.3.3.3 255.255.255.255 Serial1/0 //因为用环回口建邻居,必须保证有路由
实验结果:
show 命令,只有通告的路由才在吗?
#lab BGP2# 下一跳是MA网络
实验拓扑:
配置:
R1-
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 134.1.1.1 255.255.255.0
duplex auto
speed auto
!
interface Serial1/0
ip address 12.1.1.1 255.255.255.0
serial restart-delay 0
!
router rip
version 2
network 1.0.0.0
network 134.1.0.0
no auto-summary
!
router bgp 1
no synchronization
bgp router-id 1.1.1.1
bgp log-neighbor-changes
neighbor 3.3.3.3 remote-as 1
neighbor 3.3.3.3 update-source Loopback0
neighbor 3.3.3.3 next-hop-self
neighbor 12.1.1.2 remote-as 2
no auto-summary
!
R2-
interface Loopback0
ip address 2.2.2.2 255.255.255.0
!
interface Serial1/0
ip address 12.1.1.2 255.255.255.0
serial restart-delay 0
!
router bgp 2
no synchronization
bgp router-id 2.2.2.2
bgp log-neighbor-changes
network 2.2.2.0 mask 255.255.255.0 //通告路由
neighbor 12.1.1.1 remote-as 1
no auto-summary
!
R3-
interface Loopback0
ip address 3.3.3.3 255.255.255.0
!
interface FastEthernet0/0
ip address 134.1.1.3 255.255.255.0
duplex auto
speed auto
!
router rip
version 2
network 3.0.0.0
network 134.1.0.0
no auto-summary
!
router bgp 1
no synchronization
bgp router-id 3.3.3.3
bgp log-neighbor-changes
neighbor 1.1.1.1 remote-as 1
neighbor 1.1.1.1 update-source Loopback0
neighbor 134.1.1.4 remote-as 4
no auto-summary
!
R4-
interface Loopback0
ip address 4.4.4.4 255.255.255.0
!
interface FastEthernet0/0
ip address 134.1.1.4 255.255.255.0
duplex auto
speed auto
!
router bgp 4
no synchronization
bgp router-id 4.4.4.4
bgp log-neighbor-changes
neighbor 134.1.1.3 remote-as 1
no auto-summary
!
实验结果:
#lab BGP3# 路由聚合方法一
实验拓扑:
配置:
interface Loopback0
ip address 1.1.1.1 255.255.255.0
!
interface FastEthernet0/0
ip address 134.1.1.1 255.255.255.0
duplex auto
speed auto
!
interface Serial1/0
ip address 12.1.1.1