目录
1.配IP 环回
2.AS 2中r2 r3 r4私网内部先做IGP 起OSPF
3.r1 r2之间建立EBGP直连邻居关系
4.AS 2中r2 r3建立IBGP,环回接口建邻
5.r3 r4之间环回接口建邻
6.r4 r5之间 EBGP非直连建邻,需修改TTL值
7.r1 r5之间各发布一条路由
8.测试连通性
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[r1-GigabitEthernet0/0/0]int l0
[r1-LoopBack0]ip add 1.1.1.1 24
[r2]ospf 1 router-id 2.2.2.2
[r2-ospf-1]a 0
[r2-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[r2-ospf-1-area-0.0.0.0]network 2.2.2.2 0.0.0.0
[r3]ospf 1 router-id 3.3.3.3
[r3-ospf-1]a 0
[r3-ospf-1-area-0.0.0.0]network 23.0.0.0 0.0.0.255
[r3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
[r3-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[r4]ospf 1 router-id 4.4.4.4
[r4-ospf-1]a 0
[r4-ospf-1-area-0.0.0.0]network 34.0.0.0 0.0.0.255
[r4-ospf-1-area-0.0.0.0]network 4.4.4.4 0.0.0.0
[r1]bgp 1 //启动BGP进程
[r1-bgp]router-id 1.1.1.1 //配置RID
[r1-bgp]peer 12.0.0.2 as-number 2 //手动指定邻居关系(双向)
[r2]bgp 2
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 12.0.0.1 as-number 1
[r2]display bgp peer //查看BGP邻居表
BGP local router ID : 2.2.2.2
Local AS number : 2
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
12.0.0.1 4 1 7 7 0 00:05:19 Established
0
[r2]
在指定邻居关系时,指定的IP地址作为后续的更新源IP,如果对等体发送的数据报
中的源IP地址和给定的地址不同,则也将影响邻居关系的建立。
[r2]bgp 2
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0 //给3.3.3.3发消息使用环回接口的IP地址
[r3] bgp 2
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as-number 2
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r3-bgp]disp bgp peer
BGP local router ID : 3.3.3.3
Local AS number : 2
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
2.2.2.2 4 2 2 3 0 00:00:35 Established
0
[r3-bgp]
[r3-bgp]peer 4.4.4.4 as-number 2
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r4]bgp 2
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 3.3.3.3 as-number 2
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r4-bgp]dis bgp peer
BGP local router ID : 4.4.4.4
Local AS number : 2
Total number of peers : 1 Peers in established state : 1
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
3.3.3.3 4 2 2 2 0 00:00:02 Established
0
[r4-bgp]
[r4]ip route-static 5.5.5.5 32 45.0.0.2 //使用静态路由保证建邻IP的可达性
[r5]ip route-static 4.4.4.0 24 45.0.0.1
[r4]bgp 2
[r4-bgp]peer 5.5.5.5 as-number 3
[r4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2 //修改EBGP对等体之间发送数据报中的TTL值
[r5]bgp 3
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 4.4.4.4 as-number 2
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r5-bgp]peer 4.4.4.4 ebgp-max-hop //将TTL值修改为最大值255
[r1-bgp]network 1.1.1.0 24 //路由发布
[r1]dis bgp routing-table //查看BGP表
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
*> 1.1.1.0/24 0.0.0.0 0 0 i
[r1]
[r3]dis bgp routing-table
BGP Local router ID is 3.3.3.3
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
i 1.1.1.0/24 12.0.0.1 0 100 0 1i
[r2-bgp]peer 3.3.3.3 next-hop-local //将下一跳属性修改为自身
[r3]dis bgp routing-table
BGP Local router ID is 3.3.3.3
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
*>i 1.1.1.0/24 2.2.2.2 0 100 0 1i
[r3]
可用且优即可加表
IBGP水平分割的做法是 --- 要求当路由器从一个IBGP对等体出学习到某条BGP路
由时,他将不再把这条路由信息通告给其他的IBGP对等体。
r2 r4建立邻居关系,直接将路由信息发送给r4
[r2]bgp 2
[r2-bgp]peer 4.4.4.4 as 2
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r4]bgp 2
[r4-bgp]peer 2.2.2.2 as 2
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r2-bgp]peer 4.4.4.4 next-hop-local
r5发布路由
[r5-bgp]network 5.5.5.0 24
[r5-bgp]dis bgp routing-table
BGP Local router ID is 5.5.5.5
Status codes: * - valid, > - best, d - damped,
h - history, i - internal, s - suppressed, S - Stale
Origin : i - IGP, e - EGP, ? - incomplete
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.0/24 4.4.4.4 0 2 1i
*> 5.5.5.0/24 0.0.0.0 0 0 i
[r5-bgp]
[r4-bgp]peer 3.3.3.3 next-hop-local
[r4-bgp]peer 2.2.2.2 next-hop-local