配置IP地址,ping直连检验连通性(略)
配置AS 100内的OSPF(取R3配置):
[R3]ospf 1
[R3-ospf-1]area 0
[R3-ospf-1-area-0.0.0.0]network 10.0.23.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 10.0.34.3 0.0.0.0
[R3-ospf-1-area-0.0.0.0]network 3.3.3.3 0.0.0.0
查看OSPF邻居表:
[R3]dis ospf peer brief
OSPF Process 1 with Router ID 10.0.23.3
Peer Statistic Information
----------------------------------------------------------------------------
Area Id Interface Neighbor id State
0.0.0.0 GigabitEthernet0/0/0 10.0.23.2 Full
0.0.0.0 GigabitEthernet0/0/1 10.0.34.4 Full
----------------------------------------------------------------------------
[R3]
#状态为full,表明邻接关系建立成功。
配置BGP:
[R1]bgp 200
[R1-bgp]peer 10.0.12.2 as-number 100
[R1-bgp]peer 10.0.12.2 ebgp-max-hop 2
[R2]bgp 100
[R2-bgp]peer 4.4.4.4 as-number 100
[R2-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[R2-bgp]peer 10.0.12.1 as-number 200
[R2-bgp]peer 4.4.4.4 next-hop-local
[R4]bgp 100
[R4-bgp]peer 2.2.2.2 as-number 100
[R4-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[R4-bgp]peer 10.0.45.5 as-number 300
[R4-bgp]peer 2.2.2.2 next-hop-local --向邻居转发路由是修改下一跳为本地
[R5]bgp 300
[R5-bgp]peer 10.0.45.4 as-number 100
[R5-bgp]peer 10.0.45.4 ebgp-max-hop 2 --ebgp默认传递报文的ttl值为1,用环回口建立需要修改跳数。
查看BGP的邻居表:
[R4]dis bgp peer
BGP local router ID : 10.0.34.4
Local AS number : 100
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 100 20 20 0 00:18:17 Established
0
10.0.45.5 4 300 2 3 0 00:00:00 Established
0
[R4]
# 当状态为Established就代表建立成功。
在R1,R5上创建业务网段路由,并宣告进OSPF
[R1-bgp]network 1.1.1.1 32
[R5-bgp]network 5.5.5.5 32
在R1上,R5上查看 BGP路由表:
[R1]dis ip routing-table protocol bgp
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : BGP
Destinations : 1 Routes : 1
BGP routing table status :
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
5.5.5.5/32 EBGP 255 0 RD 10.0.12.2 GigabitEthernet
0/0/0
BGP routing table status :
Destinations : 0 Routes : 0
[R1]
[R5]dis ip routing-table protocol bgp
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : BGP
Destinations : 1 Routes : 1
BGP routing table status :
Destinations : 1 Routes : 1
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 EBGP 255 0 RD 10.0.45.4 GigabitEthernet
0/0/0
BGP routing table status :
Destinations : 0 Routes : 0
[R5]
#发现R1,R5上路由表内都存在对方的业务网段路由,
在R1上tracertR5的业务网段:
tracert -a 1.1.1.1 5.5.5.5
traceroute to 5.5.5.5(5.5.5.5), max hops: 30 ,packet length: 40,press CTRL_C t
o break
1 10.0.12.2 50 ms 20 ms 10 ms
2 * * *
3 * * *
#访问不了,是为什么呢?发现能到达R1,以此排错,查看本地路由表是否有图中经过的路由
查看R3的全局路由表:
dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 13 Routes : 13
Destination/Mask Proto Pre Cost Flags NextHop Interface
2.2.2.2/32 OSPF 10 1 D 10.0.23.2 GigabitEthernet
0/0/0
3.3.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack0
4.4.4.4/32 OSPF 10 1 D 10.0.34.4 GigabitEthernet
0/0/1
10.0.23.0/24 Direct 0 0 D 10.0.23.3 GigabitEthernet
0/0/0
10.0.23.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.0.23.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.0.34.0/24 Direct 0 0 D 10.0.34.3 GigabitEthernet
0/0/1
10.0.34.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
10.0.34.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
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
#发现并没有到达R1,R5业务网段的路由,所以访问就在这里中断了。
#所以我们需要在R3,R4上将BGP路由重发布到OSPF.
在R2,R4上将BGP路由重发布到OSPF:
[R2-ospf-1]import-route bgp
[R4-ospf-1]import-route bgp
再次查看R3路由表:
[R3]dis ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
Destinations : 15 Routes : 15
Destination/Mask Proto Pre Cost Flags NextHop Interface
1.1.1.1/32 O_ASE 150 1 D 10.0.23.2 GigabitEthernet
0/0/0
2.2.2.2/32 OSPF 10 1 D 10.0.23.2 GigabitEthernet
0/0/0
3.3.3.3/32 Direct 0 0 D 127.0.0.1 LoopBack0
4.4.4.4/32 OSPF 10 1 D 10.0.34.4 GigabitEthernet
0/0/1
5.5.5.5/32 O_ASE 150 1 D 10.0.34.4 GigabitEthernet
0/0/1
10.0.23.0/24 Direct 0 0 D 10.0.23.3 GigabitEthernet
0/0/0
10.0.23.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.0.23.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/0
10.0.34.0/24 Direct 0 0 D 10.0.34.3 GigabitEthernet
0/0/1
10.0.34.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
10.0.34.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet
0/0/1
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
[R3]
#发现已经有了业务网段的路由
在R1上带源地址 1.1.1.1访问5.5.5.5
[R1]ping -a 1.1.1.1 5.5.5.5
PING 5.5.5.5: 56 data bytes, press CTRL_C to break
Reply from 5.5.5.5: bytes=56 Sequence=1 ttl=252 time=70 ms
Reply from 5.5.5.5: bytes=56 Sequence=2 ttl=252 time=40 ms
Reply from 5.5.5.5: bytes=56 Sequence=3 ttl=252 time=40 ms
Reply from 5.5.5.5: bytes=56 Sequence=4 ttl=252 time=40 ms
Reply from 5.5.5.5: bytes=56 Sequence=5 ttl=252 time=60 ms
--- 5.5.5.5 ping statistics ---
5 packet(s) transmitted
5 packet(s) received
0.00% packet loss
round-trip min/avg/max = 40/50/70 ms
[R1]
本次BGP黑洞实验,主要查看对BGP路由传递的理解,和对路由器三种协议表的理解,通过分析三种协议表,来实行路由重发布。达到互通