实验拓扑
实验要求
1.使得路由条目全部加表,以及优选
实验内容
实验思路:
1.配置ip地址
2.R1-R2和R4,R5之间使用EBGP。R2,R3,R4之间使用IBGP
3.写路由
4.简单的查看一些路由器的bgp peer表,看是否加表
5.查看选路是否为优,是否加表
首先
给每台路由器配置ip地址
R1
[Huawei]sys r1
[r1]int lo0
[r1-LoopBack0]ip add 1.1.1.1 24
[r1-LoopBack0]q
[r1]int g0/0/0
[r1-GigabitEthernet0/0/0]ip add 12.1.1.1 24
R2
[r2]int lo0
[r2-LoopBack0]ip add 2.2.2.2 24
[r2-LoopBack0]q
[r2]int g0/0/0
[r2-GigabitEthernet0/0/0]ip add 12.1.1.2 24
[r2-GigabitEthernet0/0/0]int g0/0/1
[r2-GigabitEthernet0/0/1]ip add 23.1.1.1 24
R3
[Huawei]sys r3
[r3]int lo0
[r3-LoopBack0]ip add 3.3.3.3 24
[r3-LoopBack0]int g0/0/0
[r3-GigabitEthernet0/0/0]ip add 23.1.1.2 24
[r3-GigabitEthernet0/0/0]int g0/0/1
[r3-GigabitEthernet0/0/1]ip add 34.1.1.1 24
R4
[Huawei]sys r4
[r4]int lo0
[r4-LoopBack0]ip add 4.4.4.4 24
[r4-LoopBack0]int g0/0/1
[r4-GigabitEthernet0/0/1]ip add 45.1.1.1 24
[r4-GigabitEthernet0/0/1]int g0/0/0
[r4-GigabitEthernet0/0/0]ip add 34.1.1.2 24
[r4-GigabitEthernet0/0/0]int g0/0/2
[r4-GigabitEthernet0/0/2]ip add 54.1.1.1 24
R5
[Huawei]sys r5
[r5]int lo0
[r5-LoopBack0]ip add 5.5.5.5 24
[r5-LoopBack0]int g0/0/0
[r5-GigabitEthernet0/0/0]ip add 45.1.1.2 24
[r5-GigabitEthernet0/0/0]int g0/0/1
[r5-GigabitEthernet0/0/1]ip add 54.1.1.2 24
地址配置完成开始起 bgp
注意:一定要配置两两环回之间的路由,并且查看是否会通
R1
r1-bgp]router-id 1.1.1.1
[r1-bgp]peer 2.2.2.2 as
[r1-bgp]peer 2.2.2.2 as-number 2
[r1-bgp]peer 2.2.2.2 con
[r1-bgp]peer 2.2.2.2 connect-interface lo
[r1-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r1-bgp]peer 2.2.2.2 ebgp
[r1-bgp]peer 2.2.2.2 ebgp-max-hop 2
[r1]ip route-static 2.2.2.0 24 12.1.1.2
R2
[r2]bgp 2
[r2-bgp]route
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 1.1.1.1 as
[r2-bgp]peer 1.1.1.1 as-nu
[r2-bgp]peer 1.1.1.1 as-number 1
[r2-bgp]peer 1.1.1.1 conn
[r2-bgp]peer 1.1.1.1 connect-interface lo
[r2-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[r2-bgp]peer 1.1.1.1 ebgp
[r2-bgp]peer 1.1.1.1 ebgp-max-hop 2
[r2]ip route-static 1.1.1.0 24 12.1.1.1
[r2]display bgp routing-table
[r2]bgp 2
[r2-bgp]router-
[r2-bgp]router-id 2.2.2.2
[r2-bgp]peer 3.3.3.3 as-
[r2-bgp]peer 3.3.3.3 as-number 2
[r2-bgp]peer 3.3.3.3 conn
[r2-bgp]peer 3.3.3.3 connect-interface lo
[r2-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r2-bgp]peer 4.4.4.4 as
[r2-bgp]peer 4.4.4.4 as-number 2
[r2-bgp]peer 4.4.4.4 conn
[r2-bgp]peer 4.4.4.4 connect-interface lo
[r2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
R3
[r3]bgp 2
[r3-bgp]router
[r3-bgp]router-id 3.3.3.3
[r3-bgp]peer 2.2.2.2 as
[r3-bgp]peer 2.2.2.2 as-number 2
[r3-bgp]peer 2.2.2.2 conn
[r3-bgp]peer 2.2.2.2 connect-interface lo
[r3-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r3-bgp]peer 4.4.4.4 as
[r3-bgp]peer 4.4.4.4 as-number 2
[r3-bgp]peer 4.4.4.4
[r3-bgp]peer 4.4.4.4 conn
[r3-bgp]peer 4.4.4.4 connect-interface lo
[r3-bgp]peer 4.4.4.4 connect-interface LoopBack 0
R4
[r4]bgp 2
[r4-bgp]peer router
[r4-bgp]router
[r4-bgp]router-id 4.4.4.4
[r4-bgp]peer 2.2.2.2 as
[r4-bgp]peer 2.2.2.2 as-number 2
[r4-bgp]peer 2.2.2.2 conn
[r4-bgp]peer 2.2.2.2 connect-interface lo
[r4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[r4-bgp]peer 3.3.3.3 as
[r4-bgp]peer 3.3.3.3 as-number 2
[r4-bgp]peer 3.3.3.3 conn
[r4-bgp]peer 3.3.3.3 connect-interface lo
[r4-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[r4]bgp 2
[r4-bgp]peer 5.5.5.5 as
[r4-bgp]peer 5.5.5.5 as-number 3
[r4-bgp]peer 5.5.5.5 con
[r4-bgp]peer 5.5.5.5 connect-interface lo
[r4-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[r4-bgp]peer 5.5.5.5 ebgp
[r4-bgp]peer 5.5.5.5 ebgp-max-hop 2
[r4]ip route-s
[r4]ip route-static 5.5.5.0 24 45.1.1.2
[r4]ip route-static 5.5.5.0 24 54.1.1.2
R5
[r5]bgp 3
[r5-bgp]router
[r5-bgp]router-id 5.5.5.5
[r5-bgp]peer 4.4.4.4 as
[r5-bgp]peer 4.4.4.4 as-number 2
[r5-bgp]peer 4.4.4.4 conn
[r5-bgp]peer 4.4.4.4 connect-interface lo
[r5-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[r5-bgp]peer 4.4.4.4 ebgp
[r5-bgp]peer 4.4.4.4 ebgp-max-hop 2
[r5]ip route-s
[r5]ip route-static 4.4.4.0 24 45.1.1.1
[r5]ip route-static 4.4.4.0 24 54.1.1.1
看是否建立tcp会话以及生成相应的邻居表
R2
[r2]display tcp status
TCPCB Tid/Soid Local Add:port Foreign Add:port VPNID State
b4cf7f78 6 /1 0.0.0.0:23 0.0.0.0:0 23553 Listening
b4cf8488 164/1 0.0.0.0:179 1.1.1.1:0 0 Listening
b4cf85cc 164/4 2.2.2.2:50185 1.1.1.1:179 0 Established
r2>display bgp peer
BGP local router ID : 2.2.2.2
Local AS number : 2
Total number of peers : 3 Peers in established state : 3
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
1.1.1.1 4 1 223 223 0 03:41:52 Established
0
3.3.3.3 4 2 67 69 0 01:05:29 Established
0
4.4.4.4 4 2 65 68 0 01:04:00 Established
R3
[r3]display tcp status
TCPCB Tid/Soid Local Add:port Foreign Add:port VPNID State
b4cb2f78 6 /1 0.0.0.0:23 0.0.0.0:0 23553 Listening
b4cb3710 164/2 0.0.0.0:179 2.2.2.2:0 0 Listening
b4cb3998 164/6 0.0.0.0:179 4.4.4.4:0 0 Listening
b4cb3adc 164/12 3.3.3.3:179 4.4.4.4:50498 0 Established
b4cb3854 164/4 3.3.3.3:49544 2.2.2.2:179 0 Established
<r3>display bgp peer
BGP local router ID : 3.3.3.3
Local AS number : 2
Total number of peers : 2 Peers in established state : 2
Peer V AS MsgRcvd MsgSent OutQ Up/Down State Pre
fRcv
2.2.2.2 4 2 68 68 0 01:06:36 Established
0
4.4.4.4 4 2 66 68 0 01:04:43 Established
0
给R1上在配置一个环回
[r1]int lo1
[r1-LoopBack1]ip add 192.16.1.1 24
在R1上bgp中宣告
[r1]bgp 1
[r1-bgp]net
[r1-bgp]network 192.16.1.0 24
查看R2的BGP表
<r2>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/Ogn
*> 192.16.1.0 1.1.1.1 0 0 1i
*代表优,可以进行加表,>代表可用,i代表通过IBGP学习到的
查看R3的BGP表
<r3>display 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 192.16.1.0 1.1.1.1 0 100 0 1i
可以发现显示为i,下一跳为1.1.1.1,为下一跳不可达
我们则需要在R2上修改属性为本地
R2
[r2]bgp 2
[r2-bgp]peer 3.3.3.3 next-hop-local
再次查看R3的bgp表
<r3>display 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 192.16.1.0 2.2.2.2 0 100 0 1i
修改后,这个网段则为优了
同理
查看R4的BGP表
[r4]display bgp routing-table
BGP Local router ID is 4.4.4.4
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 192.16.1.0 1.1.1.1 0 100 0 1i
将R4的属性修改为本地
查看R5的BGP表
[r5-bgp]display 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: 1
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 192.16.1.0 4.4.4.4 0 2 1i
这样全部加表,选路最优了
实验结束。