基础配置
display ip interface brief
Interface IP Address/Mask Physical Protocol
GigabitEthernet0/0/0 12.0.0.2/24 up up
GigabitEthernet0/0/1 172.16.1.1/29 up up
GigabitEthernet0/0/2 172.16.1.9/29 up up
LoopBack0 172.16.2.1/24 up up(s)
NULL0 unassigned up up(s)
路由配置
接着在AS2区域中,启用OSPF协议,保证互相之间能够通讯
[R2]ospf 1 router-id 2.2.2.2
[R2-ospf-1]area 0
[R2-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.0.255
[R3]ospf 1 router-id 3.3.3.3
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 172.16.0.0 0.0.255.255
查看各个路由器上OSPF路由表
[R3]display ip routing-table protocol ospf
Route Flags: R - relay, D - download to fib
Public routing table : OSPF
Destinations : 9 Routes : 10
OSPF routing table status :
Destinations : 9 Routes : 10
Destination/Mask Proto Pre Cost Flags NextHop Interface
172.16.1.8/29 OSPF 10 2 D 172.16.1.1 GigabitEthernet0/0/0
172.16.1.24/29 OSPF 10 2 D 172.16.1.18 GigabitEthernet0/0/1
172.16.1.32/29 OSPF 10 3 D 172.16.1.1 GigabitEthernet0/0/0
172.16.1.40/29 OSPF 10 3 D 172.16.1.18 GigabitEthernet0/0/1
172.16.2.1/32 OSPF 10 1 D 172.16.1.1 GigabitEthernet0/0/0
172.16.4.1/32 OSPF 10 1 D 172.16.1.18 GigabitEthernet0/0/1
172.16.5.1/32 OSPF 10 2 D 172.16.1.1 GigabitEthernet0/0/0
172.16.6.1/32 OSPF 10 3 D 172.16.1.1 GigabitEthernet0/0/0
OSPF 10 3 D 172.16.1.18 GigabitEthernet0/0/1
172.16.7.1/32 OSPF 10 2 D 172.16.1.18 GigabitEthernet0/0/1
OSPF routing table status :
Destinations : 0 Routes : 0
然后是启动AS之间的BGP协议
[R1]bgp 1
[R1-bgp]router-id 1.1.1.1
[R1-bgp]peer 12.0.0.2 as-number 2
[R2]bgp 64512 ---- 有联邦存在的时候写联邦AS号
[R2-bgp]router-id 2.2.2.2
[R2-bgp]confederation id 2 — 告诉大AS号为2
[R2-bgp]confederation peer-as 64513 — 指定EBGP对等体关系的AS号
[R2-bgp]peer 12.0.0.1 as-number 1
[R2-bgp]peer 172.16.3.1 as-number 64512 — 建立 R2 与 R3 的IGP对等体关系
[R2-bgp]peer 172.16.3.1 connect-interface LoopBack 0
[R2-bgp]peer 172.16.5.1 as-number 64513 — 建立 R2 与 R5 的非直连建邻
[R2-bgp]peer 172.16.5.1 connect-interface LoopBack 0
[R2-bgp]peer 172.16.5.1 ebgp-max-hop — 将ttl值修改
[R3]bgp 64512
[R3-bgp]router-id 3.3.3.3
[R3-bgp]confederation id 2
[R3-bgp]peer 172.16.2.1 as-number 64512
[R3-bgp]peer 172.16.2.1 connect-interface LoopBack 0
[R3-bgp]peer 172.16.4.1 as-number 64512
[R3-bgp]peer 172.16.4.1 connect-interface LoopBack 0
[R4]bgp 64512
[R4-bgp]router-id 4.4.4.4
[R4-bgp]confederation id 2
[R4-bgp]confederation peer-as 64513
[R4-bgp]peer 172.16.3.1 as 64512
[R4-bgp]peer 172.16.3.1 connect-interface LoopBack 0
[R4-bgp]peer 172.16.7.1 as 64513
[R4-bgp]peer 172.16.7.1 connect-interface LoopBack 0
[R4-bgp]peer 172.16.7.1 ebgp-max-hop
[R8]bgp 3
[R8-bgp]router-id 8.8.8.8
[R8-bgp]peer 78.0.0.1 as 2
查看一下BGP邻居关系
R2
[R2]display bgp peer
BGP local router ID : 2.2.2.2
Local AS number : 64512
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
12.0.0.1 4 1 19 19 0 00:17:28 Established 0
172.16.3.1 4 64512 14 16 0 00:12:21 Established 0
172.16.5.1 4 64513 8 10 0 00:06:11 Established 0
R3
[R3]display bgp peer
BGP local router ID : 3.3.3.3
Local AS number : 64512
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State PrefRcv
172.16.2.1 4 64512 14 14 0 00:12:49 Established 0
172.16.4.1 4 64512 11 14 0 00:09:49 Established 0
发布R1路由
[R1-bgp]network 10.0.0.0 24
[R1-bgp]display bgp peer
查看BGP路由表
[R1-bgp]display 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: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.0.0.0/24 0.0.0.0 0 0 i
display bgp routing-table
BGP Local router ID is 2.2.2.2
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Og
*> 10.0.0.0/24 12.0.0.1 0 0 1i
AS2内部环回路由信息互相访问
先进行路由聚合
配置空接口,再进行静态路由的发布
[R1]display 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: 3
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.0.0.0/24 0.0.0.0 0 0 i
*> 11.0.0.0/24 12.0.0.2 0 2 3i
*> 172.16.0.0/21 12.0.0.2 0 0 2i
制作GRE隧道
[R1]int t 0/0/0
[R1-Tunnel0/0/0]ip address 99.0.0.1 24
[R1-Tunnel0/0/0]tunnel-protocol gre
[R1-Tunnel0/0/0]source 10.0.0.1
[R1-Tunnel0/0/0]destination 11.0.0.1
[R8]int t 0/0/0
[R8-Tunnel0/0/0]ip address 99.0.0.2 24
[R8-Tunnel0/0/0]tunnel-protocol gre
[R8-Tunnel0/0/0]source 11.0.0.1
[R8-Tunnel0/0/0]destination 10.0.0.1
配置静态路由
[R1]ip route-static 192.168.2.0 24 99.0.0.2
[R8]ip route-static 192.168.1.0 24 99.0.0.1