当BGP路由传递出本地AS时,会在as-path属性中添加本地ASN作为成员;这一属性是eBGP重要的防环参考依据。
实验拓扑如下:
完成实验拓扑的基础配置R1如下:
hostname R1
!
interface Loopback0
ip address 10.1.0.1 255.255.255.0
!
interface Loopback1
ip address 10.1.1.1 255.255.255.0
!
interface Ethernet0/0
ip address 100.98.12.1 255.255.255.0
no sh
!
router bgp 11
bgp router-id 1.1.1.1
network 10.1.0.0 mask 255.255.255.0
network 10.1.1.0 mask 255.255.255.0
aggregate-address 10.1.0.0 255.255.252.0 summary-only
neighbor 100.98.12.2 remote-as 23
!
end
基础配置R2如下:
hostname R2
!
interface Ethernet0/0
ip address 100.98.12.2 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 10.23.1.2 255.255.255.0
no sh
!
router bgp 23
bgp router-id 2.2.2.2
neighbor 10.23.1.3 remote-as 23
neighbor 10.23.1.3 next-hop-self
neighbor 100.98.12.1 remote-as 11
!
end
基础配置R3如下:
hostname R3
!
interface Ethernet0/0
ip address 10.23.1.3 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 100.99.34.3 255.255.255.0
no sh
!
router bgp 23
bgp router-id 3.3.3.3
neighbor 10.23.1.2 remote-as 23
neighbor 10.23.1.2 next-hop-self
neighbor 100.99.34.4 remote-as 44
!
end
基础配置R4如下:
hostname R4
!
interface Loopback0
ip address 4.4.4.4 255.255.255.255
!
interface Ethernet0/0
ip address 100.99.34.4 255.255.255.0
no sh
!
interface Ethernet0/1
ip address 100.100.45.4 255.255.255.0
no sh
!
router bgp 44
bgp router-id 4.4.4.4
network 4.4.4.4 mask 255.255.255.255
neighbor 100.99.34.3 remote-as 23
neighbor 100.100.45.5 remote-as 55
!
end
基础配置R5如下:
hostname R5
!
interface Loopback0
ip address 10.1.2.1 255.255.255.0
!
interface Loopback1
ip address 10.1.3.1 255.255.255.0
!
interface Ethernet0/0
ip address 100.100.45.5 255.255.255.0
no sh
!
router bgp 55
bgp router-id 5.5.5.5
network 10.1.2.0 mask 255.255.255.0
network 10.1.3.0 mask 255.255.255.0
aggregate-address 10.1.0.0 255.255.252.0 summary-only
neighbor 100.100.45.4 remote-as 44
!
end
等待BGP完成收敛后,观察R3和R4去往目标网络10.1.0.0/22的路由,这时可以看到优选路径都是其最短AS-PATH。
在R5上增加配置如下:
route-map ADDASN permit 10
set as-path prepend 56 57 58 59 60
!
router bgp 55
neighbor 100.100.45.4 route-map ADDASN out
!
end
cle ip b * so o
当使用as-path属性做出选路决策时,BGP会选择历经AS比较少的路由,即as-path较短的路径。
PS://使用多出口鉴别器属性可以用于多宿主环境操控本地AS的入站流量。
如果一条BGP路由携带周知团队属性值0xFFFFFF01,那么该路由不能传递给eBGP对等体。