R4:
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn*> 10.10.4.4/32 0.0.0.0 0 0 i
R1:
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn*> 10.10.4.4/32 192.168.14.4 0 0 100i
i 10.10.5.5/32 192.168.35.5 0 100 0 300i
R3:
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogni 10.10.4.4/32 192.168.14.4 0 100 0 100i
*> 10.10.5.5/32 192.168.35.5 0 0 300i
R5:
Total Number of Routes: 1
Network NextHop MED LocPrf PrefVal Path/Ogn*> 10.10.5.5/32 0.0.0.0 0 0 i
2)从外部邻居哪里学来的路由,在传递给自己的内部邻居时,默认不修改下一跳地址
R5:
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn*> 10.10.5.5/32 0.0.0.0 0 0 i
*> 10.10.7.7/32 0.0.0.0 0 0 i
R3:
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogni 10.10.4.4/32 192.168.14.4 0 100 0 100i
*> 10.10.5.5/32 192.168.35.5 0 0 300i
i 10.10.6.6/32 192.168.14.4 0 100 0 100i
*> 10.10.7.7/32 192.168.35.5 0 0 300i
R1:
Total Number of Routes: 4
Network NextHop MED LocPrf PrefVal Path/Ogn*> 10.10.4.4/32 192.168.14.4 0 0 100i
i 10.10.5.5/32 192.168.35.5 0 100 0 300i
*> 10.10.6.6/32 192.168.14.4 0 0 100i
i 10.10.7.7/32 192.168.35.5 0 100 0 300iR4:
Total Number of Routes: 2
Network NextHop MED LocPrf PrefVal Path/Ogn*> 10.10.4.4/32 0.0.0.0 0 0 i
*> 10.10.6.6/32 0.0.0.0 0 0 i
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: 2
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.10.4.4/32 0.0.0.0 0 0 i
*> 10.10.6.6/32 0.0.0.0 0 0 i
[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: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*> 10.10.4.4/32 192.168.14.4 0 0 100i
i 10.10.5.5/32 192.168.35.5 0 100 0 300i
*> 10.10.6.6/32 192.168.14.4 0 0 100i
i 10.10.7.7/32 192.168.35.5 0 100 0 300i
[R1-bgp]
[R3-bgp]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: 4
Network NextHop MED LocPrf PrefVal Path/Ogn
*>i 10.10.4.4/32 192.168.12.1 0 100 0 100i
*> 10.10.5.5/32 192.168.35.5 0 0 300i
*>i 10.10.6.6/32 192.168.12.1 0 100 0 100i
*> 10.10.7.7/32 192.168.35.5 0 0 300i
[R3-bgp]
[R1-bgp]display fib
Route Flags: G - Gateway Route, H - Host Route, U - Up Route
S - Static Route, D - Dynamic Route, B - Black Hole Route
L - Vlink Route
--------------------------------------------------------------------------------
FIB Table:
Total number of Routes : 13
Destination/Mask Nexthop Flag TimeStamp Interface TunnelID
10.10.6.6/32 192.168.14.4 DGHU t[1744] GE0/0/1 0x0
10.10.4.4/32 192.168.14.4 DGHU t[47] GE0/0/1 0x0
192.168.14.255/32 127.0.0.1 HU t[21] InLoop0 0x0
192.168.14.1/32 127.0.0.1 HU t[21] InLoop0 0x0
192.168.12.255/32 127.0.0.1 HU t[14] InLoop0 0x0
192.168.12.1/32 127.0.0.1 HU t[14] InLoop0 0x0
255.255.255.255/32 127.0.0.1 HU t[4] InLoop0 0x0
127.255.255.255/32 127.0.0.1 HU t[4] InLoop0 0x0
127.0.0.1/32 127.0.0.1 HU t[4] InLoop0 0x0
127.0.0.0/8 127.0.0.1 U t[4] InLoop0 0x0
192.168.12.0/24 192.168.12.1 U t[14] GE0/0/0 0x0
192.168.14.0/24 192.168.14.1 U t[21] GE0/0/1 0x0
192.168.23.0/24 192.168.12.2 DGU t[1146] GE0/0/0 0x0
[R1-bgp]
display fib
Route Flags: G - Gateway Route, H - Host Route, U - Up Route
S - Static Route, D - Dynamic Route, B - Black Hole Route
L - Vlink Route
--------------------------------------------------------------------------------
FIB Table:
Total number of Routes : 15
Destination/Mask Nexthop Flag TimeStamp Interface TunnelID
10.10.4.4/32 192.168.23.2 DGHU t[3211] GE0/0/0 0x0
10.10.6.6/32 192.168.23.2 DGHU t[3211] GE0/0/0 0x0
10.10.7.7/32 192.168.35.5 DGHU t[1710] GE0/0/1 0x0
10.10.5.5/32 192.168.35.5 DGHU t[43] GE0/0/1 0x0
192.168.35.255/32 127.0.0.1 HU t[16] InLoop0 0x0
192.168.35.3/32 127.0.0.1 HU t[16] InLoop0 0x0
192.168.23.255/32 127.0.0.1 HU t[10] InLoop0 0x0
192.168.23.3/32 127.0.0.1 HU t[10] InLoop0 0x0
255.255.255.255/32 127.0.0.1 HU t[5] InLoop0 0x0
127.255.255.255/32 127.0.0.1 HU t[5] InLoop0 0x0
127.0.0.1/32 127.0.0.1 HU t[5] InLoop0 0x0
127.0.0.0/8 127.0.0.1 U t[5] InLoop0 0x0
192.168.23.0/24 192.168.23.3 U t[10] GE0/0/0 0x0
192.168.35.0/24 192.168.35.3 U t[16] GE0/0/1 0x0
192.168.12.0/24 192.168.23.2 DGU t[59] GE0/0/0 0x0
[RTB]bgp 200
[RTB]peer 10.1.23.3 next-hop-local // 表示用自身作为邻居的下一跳
目标是利用BGP将路由打通,IP和OSPF的配置部分略过
建立邻居
一般建立邻居关系都是用环回接口的IP,但EBGP默认情况下无法使用环回口建立邻居,所以这里用直连口IP
AR1配置:
[AR1]bgp 100 // 100表示AS号
[AR1-bgp]peer 12.1.1.2 as-number 200 // 指定对方的IP地址和AS号
AR2配置:
[AR2]bgp 200
[AR2-bgp]peer 12.1.1.1 as-number 100 // 指回来
IBGP可以使用环回口建立邻居,这里用环回口
AR2配置:
[AR2-bgp]peer 3.3.3.3 as-number 200
[AR2-bgp]peer 3.3.3.3 connect-interface LoopBack0 // 指定使用环回接口
AR3配置:
[AR3]bgp 200
[AR3-bgp]peer 2.2.2.2 as-number 200
[AR3-bgp]peer 2.2.2.2 connect-interface LoopBack0
接下来配置类似,略
宣告路由
AR1将需要告知对方的网段宣告出去
[AR1]bgp 100
[AR1-bgp]network 1.1.1.0 24
[AR1-bgp]network 12.1.1.0 24
AR2查看BGP路由表
’符号的路由才是可用路由。这里因为12.1.1.0网段是AR2路由器的直连路由,它却通过其它路由器的BGP获得,它会觉得这条路由不可信,本机也要将此网段宣告出去才会正常。
AR2宣告路由
[AR2]bgp 200
[AR2-bgp]network 12.1.1.0 24
再次查看BGP路由表
这回正常了
路由反射
查看AR3和AR4的BGP路由表
可以看到AR3是正常的,但AR4的路由表却是空的。这是因为BGP为了防止环路采用的水平分割机制,路由器从IBGP邻居那拿来的路由不会在IBGP传递。简单理解就是IBGP内的路由只能是一手,AR3的路由是从AR2那拿来的,它不会再把二手路由交给AR4。为了解决这一问题需要采用路由反射技术,将AR3的路由反射给AR4。
AR3配置路由反射
[AR3]bgp 200
[AR3-bgp]peer 4.4.4.4 reflect-client
等个1分钟,再次查看AR4路由表
正常了
宣告路由
按照上面的方法再将AR4和AR5的路由宣告出去,但这次不用再配置反射,对于配置过路由反射的路由器,BGP不会再采用水平分割机制,45网段的路由是能传递到AR1里的
路由引入
将OSPF的路由引入BGP内,OSPF内的任意路由器都可以,这里以AR2为例
[AR2]bgp 200
[AR2-bgp]import-route ospf 1
网络测试
到这里已经全网互通了,接下来就是测试连通性
RTB在接收到RTA的路由后,会给BTC和BTD都传一份,但又有一些区别
图为BGP路由表,开头的*代表路由可用,>代表最优路由,只有最优路由会存放到IP路由表中并通告给邻居