网络拓扑图:

BGP 边界网关协议_自治系统

配置代码:

R1:
enable
conf t
host r1
no ip domain-lookup
int g0/0
ip address 192.168.2.1 255.255.255.0
no shut
int g0/1
ip address 192.168.1.1 255.255.255.0
no shut
exit
router bgp 1
!1为自治系统号
neighbor 192.168.2.2 remote-as 2
!2为邻居自治系统号
neighbor 192.168.1.2 remote-as 4
network 192.168.1.0 mask 255.255.255.0
network 192.168.2.0 mask 255.255.255.0
bgp router-id 1.1.1.1

R2:
enable
conf t
host r2
no ip domain-lookup
int g0/0
ip address 192.168.2.2 255.255.255.0
no shut
int g0/1
ip address 192.168.3.1 255.255.255.0
no shut
exit
router bgp 2
!2为自治系统号
neighbor 192.168.2.1 remote-as 1
!1为邻居自治系统号
neighbor 192.168.3.2 remote-as 3
network 192.168.2.0 mask 255.255.255.0
network 192.168.3.0 mask 255.255.255.0
bgp router-id 2.2.2.2

R3:
enable
conf t
host r3
no ip domain-lookup
int g0/0
ip address 192.168.3.2 255.255.255.0
no shut
int g0/1
ip address 192.168.4.1 255.255.255.0
no shut
exit
router bgp 3
!3为自治系统号
neighbor 192.168.3.1 remote-as 2
!2为邻居自治系统号
neighbor 192.168.4.2 remote-as 4
network 192.168.3.0 mask 255.255.255.0
network 192.168.4.0 mask 255.255.255.0
bgp router-id 3.3.3.3

R4:
enable
conf t
host r4
no ip domain-lookup
int g0/0
ip address 192.168.4.2 255.255.255.0
no shut
int g0/1
ip address 192.168.1.2 255.255.255.0
no shut
exit
router bgp 4
!4为自治系统号
neighbor 192.168.4.1 remote-as 3
!3为邻居自治系统号
neighbor 192.168.1.1 remote-as 1
network 192.168.4.0 mask 255.255.255.0
network 192.168.1.0 mask 255.255.255.0
bgp router-id 4.4.4.4

配置结果:

路由表:

R1:

BGP 边界网关协议_自治系统_02

R2:

BGP 边界网关协议_R3_03

R3:

BGP 边界网关协议_R3_04

R4:

BGP 边界网关协议_边界网关协议_05

R1->R3:

BGP 边界网关协议_边界网关协议_06