组网需求
- 用户将网络划分为AS65008与AS65009
- 在AS65009中使用IGP协议来计算路由(OSPF协议)
- 要求实现两个AS之间的通信
组网拓扑
组网思路
- 在Router B与Router C之间配置OSPF协议,实现IGP内部网络互访
- 在Router A与Router B上配置EBGP,是Router A与Router B之间可通过BGP互访
- 在Router B上配置BGP与OSPF的互相引入,实现两个AS之间的互通
- 在Router B上配置BGP路由聚合,简化BGP路由表规模
配置命令
配置各个路由器基本功能以及接口IP
Router A配置
1
2
3
4
5
6
7
8sys
sys Router A
int g0/0/0
ip add 3.1.1.1 30
int LoopBack 0
ip add 8.1.1.1 32
int LoopBack 1
ip add 1.1.1.1 32
Router B配置
1
2
3
4
5
6
7
8sys
sys Router B
int g0/0/0
ip add 3.1.1.2 30
int g0/0/1
ip add 9.1.1.1 30
int LoopBack 0
ip add 2.2.2.2 32
Router C配置
1
2
3
4
5
6
7
8sys
sys Router C
int g0/0/1
ip add 9.1.1.2 30
int LoopBack 0
ip add 9.1.2.1 32
int LoopBack 1
ip add 3.3.3.3 32
配置AS65009内的IGP路由协议(OSPF)实现AS内互联互通
Router B配置
1
2
3
4
5sys
ospf 1 router-id 2.2.2.2
area 0
network 9.1.1.1 0.0.0.3
network 2.2.2.2 0.0.0.0
Router C配置
1
2
3
4
5
6sys
ospf 1 router-id 3.3.3.3
area 0
network 9.1.1.2 0.0.0.3
network 9.1.2.1 0.0.0.0
network 3.3.3.3 0.0.0.0
配置EBGP,建立EBGP邻居
Router A配置
1
2
3sys
bgp 65008
peer 3.1.1.2 as-number 65009
Router B配置
1
2
3sys
bgp 65009
peer 3.1.1.1 as-number 65008
BGP引入IGP路由(两种方式:一种network,一种import)
Router A配置
1
2
3
4sys
bgp 65008
ipv4-family unicast
network 8.1.1.1 32
Router B配置
1
2
3
4sys
bgp 65009
ipv4-family unicast
import-route ospf 1
IGP引入BGP路由
Router B配置
1
2
3sys
ospf 1
import-route bgp
配置BGP路由聚合
Router B配置
1
2
3
4sys
bgp 65009
ipv4-family unicast
summary automatic
结果查看
BGP引入IGP路由时,查看BGP路由表
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18disply bgp routing-table
<Router A>dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 5
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 2.2.2.2/32 3.1.1.2 0 0 65009?
*> 3.3.3.3/32 3.1.1.2 1 0 65009?
*> 8.1.1.1/32 0.0.0.0 0 0 i
*> 9.1.1.0/30 3.1.1.2 0 0 65009?
*> 9.1.2.1/32 3.1.1.2 1 0 65009?
IGP引入BGP路由,查看IGP路由表
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26display ip routing-table
<Router C>dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost Flags NextHop Interface
2.2.2.2/32 OSPF 10 1 D 9.1.1.1 GigabitEthernet
0/0/1
3.3.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack1
8.1.1.1/32 O_ASE 150 1 D 9.1.1.1 GigabitEthernet
0/0/1
9.1.1.0/30 Direct 0 0 D 9.1.1.2 GigabitEthernet
0/0/1
9.1.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
9.1.1.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
9.1.2.1/32 Direct 0 0 D 127.0.0.1 LoopBack0
127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
配置BGP路由聚合后的BGP路由表(以Router A为例)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17display bgp routing-table
<Router A>dis bgp routing-table
BGP Local router ID is 1.1.1.1
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 2.0.0.0 3.1.1.2 0 65009?
*> 3.0.0.0 3.1.1.2 0 65009?
*> 8.1.1.1/32 0.0.0.0 0 0 i
*> 9.0.0.0 3.1.1.2 0 65009?
结果测试
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15ping -a 8.1.1.1 9.1.2.1
<Router A>ping -a 8.1.1.1 9.1.2.1
PING 9.1.2.1: 56 data bytes, press CTRL_C to break
Reply from 9.1.2.1: bytes=56 Sequence=1 ttl=254 time=70 ms
Reply from 9.1.2.1: bytes=56 Sequence=2 ttl=254 time=30 ms
Reply from 9.1.2.1: bytes=56 Sequence=3 ttl=254 time=30 ms
Reply from 9.1.2.1: bytes=56 Sequence=4 ttl=254 time=30 ms
Reply from 9.1.2.1: bytes=56 Sequence=5 ttl=254 time=20 ms
--- 9.1.2.1 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 20/36/70 ms