AR1 配置
# R1配置 - AS100
sysname R1
# 创建环回接口
interface LoopBack0
ip address 172.16.1.1 255.255.255.0
interface LoopBack1
ip address 172.16.2.1 255.255.255.0
# 配置物理接口
interface GigabitEthernet0/0/0
ip address 12.0.0.1 255.255.255.0
# 配置BGP
bgp 100
router-id 1.1.1.1
peer 12.0.0.2 as-number 200
# 宣告汇总地址
network 172.16.0.0 255.255.0.0
[R1]display ospf peer brief
OSPF Process 1 with Router ID 1.1.1.1
Peer Statistic Information
-------------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 2.2.2.2 Full
[R1]display bgp peer
BGP local router ID : 1.1.1.1
Local AS number : 100
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
12.0.0.2 4 200 567 565 0 01:30:45 Established 5
[R1]display bgp routing-table
BGP local router ID : 1.1.1.1
Local AS number : 100
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 172.16.0.0/16 0.0.0.0 0 100 0 i
*> 2.2.2.2/32 12.0.0.2 0 0 200 i
*> 3.3.3.3/32 12.0.0.2 0 0 200 i
*> 4.4.4.4/32 12.0.0.2 0 0 200 i
*> 5.5.5.5/32 12.0.0.2 0 0 200 300 i
AR2 配置
# R2配置 - AS200
sysname R2
# 创建环回接口
interface LoopBack0
ip address 2.2.2.2 255.255.255.255
# 配置物理接口
interface GigabitEthernet0/0/0
ip address 12.0.0.2 255.255.255.0
interface GigabitEthernet0/0/1
ip address 23.0.0.2 255.255.255.0
# 配置IGP (OSPF)
ospf 1 router-id 2.2.2.2
area 0.0.0.0
network 2.2.2.2 0.0.0.0
network 23.0.0.0 0.0.0.255
# 配置BGP
bgp 200
router-id 2.2.2.2
# EBGP邻居
peer 12.0.0.1 as-number 100
# IBGP邻居
peer 3.3.3.3 as-number 200
peer 3.3.3.3 connect-interface LoopBack0
# 宣告环回地址
network 2.2.2.2 255.255.255.255
# 将OSPF路由引入BGP
import-route ospf 1
[R2]display ospf peer brief
OSPF Process 1 with Router ID 2.2.2.2
Peer Statistic Information
-------------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1 3.3.3.3 Full
[R2]display bgp peer
BGP local router ID : 2.2.2.2
Local AS number : 200
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
12.0.0.1 4 100 565 567 0 01:30:45 Established 1
3.3.3.3 4 200 456 454 0 01:25:10 Established 3
[R2]display bgp routing-table
BGP local router ID : 2.2.2.2
Local AS number : 200
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i172.16.0.0/16 12.0.0.1 0 100 0 100 i
*> 2.2.2.2/32 0.0.0.0 0 100 0 i
*>i3.3.3.3/32 23.0.0.3 0 100 0 i
*>i4.4.4.4/32 23.0.0.3 0 100 0 i
*>i5.5.5.5/32 23.0.0.3 0 100 0 300 i
AR3 配置
# R3配置 - AS200
sysname R3
# 创建环回接口
interface LoopBack0
ip address 3.3.3.3 255.255.255.255
# 配置物理接口
interface GigabitEthernet0/0/0
ip address 34.0.0.3 255.255.255.0
interface GigabitEthernet0/0/1
ip address 23.0.0.3 255.255.255.0
# 配置IGP (OSPF)
ospf 1 router-id 3.3.3.3
area 0.0.0.0
network 3.3.3.3 0.0.0.0
network 23.0.0.0 0.0.0.255
network 34.0.0.0 0.0.0.255
# 配置BGP
bgp 200
router-id 3.3.3.3
# IBGP邻居
peer 2.2.2.2 as-number 200
peer 2.2.2.2 connect-interface LoopBack0
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
# 宣告环回地址
network 3.3.3.3 255.255.255.255
[R3]display ospf peer brief
OSPF Process 1 with Router ID 3.3.3.3
Peer Statistic Information
-------------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/1 2.2.2.2 Full
0.0.0.0 GigabitEthernet0/0/0 4.4.4.4 Full
[R3]display bgp peer
BGP local router ID : 3.3.3.3
Local AS number : 200
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
2.2.2.2 4 200 454 456 0 01:25:10 Established 2
4.4.4.4 4 200 345 343 0 01:20:30 Established 2
[R3]display bgp routing-table
BGP local router ID : 3.3.3.3
Local AS number : 200
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i172.16.0.0/16 23.0.0.2 0 100 0 100 i
*>i2.2.2.2/32 23.0.0.2 0 100 0 i
*> 3.3.3.3/32 0.0.0.0 0 100 0 i
*>i4.4.4.4/32 34.0.0.4 0 100 0 i
*>i5.5.5.5/32 34.0.0.4 0 100 0 300 i
AR4配置
# R4配置 - AS200
sysname R4
# 创建环回接口
interface LoopBack0
ip address 4.4.4.4 255.255.255.255
# 配置物理接口
interface GigabitEthernet0/0/0
ip address 34.0.0.4 255.255.255.0
interface GigabitEthernet0/0/1
ip address 45.0.0.4 255.255.255.0
# 配置IGP (OSPF)
ospf 1 router-id 4.4.4.4
area 0.0.0.0
network 4.4.4.4 0.0.0.0
network 34.0.0.0 0.0.0.255
# 配置静态路由
ip route-static 5.5.5.5 255.255.255.255 45.0.0.5
# 配置BGP
bgp 200
router-id 4.4.4.4
# IBGP邻居
peer 3.3.3.3 as-number 200
peer 3.3.3.3 connect-interface LoopBack0
# EBGP邻居
peer 5.5.5.5 as-number 300
peer 5.5.5.5 connect-interface LoopBack0
peer 5.5.5.5 ebgp-max-hop 2
# 宣告环回地址和静态路由
network 4.4.4.4 255.255.255.255
network 5.5.5.5 255.255.255.255
[R4]display ospf peer brief
OSPF Process 1 with Router ID 4.4.4.4
Peer Statistic Information
-------------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 3.3.3.3 Full
[R4]display bgp peer
BGP local router ID : 4.4.4.4
Local AS number : 200
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
3.3.3.3 4 200 343 345 0 01:20:30 Established 2
5.5.5.5 4 300 234 232 0 01:15:45 Established 1
[R4]display bgp routing-table
BGP local router ID : 4.4.4.4
Local AS number : 200
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i172.16.0.0/16 34.0.0.3 0 100 0 100 i
*>i2.2.2.2/32 34.0.0.3 0 100 0 i
*>i3.3.3.3/32 34.0.0.3 0 100 0 i
*> 4.4.4.4/32 0.0.0.0 0 100 0 i
*> 5.5.5.5/32 45.0.0.5 0 0 300 i
AR5 配置
# R5配置 - AS300
sysname R5
# 创建环回接口
interface LoopBack0
ip address 5.5.5.5 255.255.255.255
# 配置物理接口
interface GigabitEthernet0/0/0
ip address 45.0.0.5 255.255.255.0
# 配置静态路由
ip route-static 4.4.4.4 255.255.255.255 45.0.0.4
# 配置BGP
bgp 300
router-id 5.5.5.5
# EBGP邻居
peer 4.4.4.4 as-number 200
peer 4.4.4.4 connect-interface LoopBack0
peer 4.4.4.4 ebgp-max-hop 2
# 宣告环回地址
network 5.5.5.5 255.255.255.255
[R5]display ospf peer brief
[R5]display bgp peer
BGP local router ID : 5.5.5.5
Local AS number : 300
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
4.4.4.4 4 200 232 234 0 01:15:45 Established 4
[R5]display bgp routing-table
BGP local router ID : 5.5.5.5
Local AS number : 300
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 5.5.5.5/32 0.0.0.0 0 100 0 i
*> 172.16.0.0/16 45.0.0.4 0 0 200 100 i
*> 2.2.2.2/32 45.0.0.4 0 0 200 i
*> 3.3.3.3/32 45.0.0.4 0 0 200 i
*> 4.4.4.4/32 45.0.0.4 0 0 200 i
验证:
<R1>ping -c 5 5.5.5.5
PING 5.5.5.5: 56 data bytes, press CTRL_C to break
Reply from 5.5.5.5: bytes=56 Sequence=1 ttl=252 time=45 ms
Reply from 5.5.5.5: bytes=56 Sequence=2 ttl=252 time=48 ms
Reply from 5.5.5.5: bytes=56 Sequence=3 ttl=252 time=50 ms
Reply from 5.5.5.5: bytes=56 Sequence=4 ttl=252 time=47 ms
Reply from 5.5.5.5: bytes=56 Sequence=5 ttl=252 time=49 ms
--- 5.5.5.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 45/47.8/50 ms
<R5>ping -c 5 172.16.1.1
PING 172.16.1.1: 56 data bytes, press CTRL_C to break
Reply from 172.16.1.1: bytes=56 Sequence=1 ttl=251 time=55 ms
Reply from 172.16.1.1: bytes=56 Sequence=2 ttl=251 time=52 ms
Reply from 172.16.1.1: bytes=56 Sequence=3 ttl=251 time=58 ms
Reply from 172.16.1.1: bytes=56 Sequence=4 ttl=251 time=53 ms
Reply from 172.16.1.1: bytes=56 Sequence=5 ttl=251 time=50 ms
--- 172.16.1.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 50/53.6/58 ms