BGP基本实验
一.实验拓扑图
二 实验步骤
[R1]bgp 30 [R1-bgp]router-id 1.1.1.1 [R1-bgp]peer 10.0.1.6 as-nu [R1-bgp]peer 10.0.1.6 as-number 10 [R1-bgp]net 10.0.1.4 ? INTEGER<0-32> Mask length of the IP address X.X.X.X Specify an ipv4 network mask route-policy Specify a route policy short-cut Specify a short-cut route <cr>
[R1-bgp]net 10.0.1.4 255.255.255.252 [R1-bgp]net 1.1.1.1 255.255.255.255 [R1-bgp]net 10.30.1.1 32 [R1-bgp]peer 10.0.1.2 as-num 40 [R1-bgp]net 10.0.1.0 255.255.255.252 [R1-bgp]
[R4]bgp 40 [R4-bgp]router-id 4.4.4.4 [R4-bgp]peer 10.0.1.1 as-num 30 [R4-bgp]peer 10.0.1. %Aug 28 20:57:25:344 2012 R4 RM/3/RMLOG: BGP.: 10.0.1.1 State is changed from OPENCONFIRM to ESTABLISHED. 10 as-num 10 [R4-bgp]net 10.0.1.0 30 [R4-bgp]net 10.0.1.8 30 [R4-bgp]net 4.4.4.4 32 [R4-bgp]net 10.40.4.1 32 [R4-bgp]
[R2]bgp 10 [R2-bgp]router-id 2.2.2.2 [R2-bgp]peer 10.0.1.5 as-num 30 [R2-bgp]net 2.2.2.2 32 [R2-bgp]net 10.0.1.5 %Aug 28 21:00:23:218 2012 R2 RM/3/RMLOG: BGP.: 10.0.1.5 State is changed from OPENCONFIRM to ESTABLISHED.
[R2-bgp]undo net 10.0.1.5 [R2-bgp]net 10.0.1.4 30 [R2-bgp]undo net 2.2.2.2 32 [R2-bgp]undo net 10.0.1.4 30 [R2-bgp]peer 3.3.3.3 as-num 10 [R2-bgp]peer 3.3.3.3 connect-int lo0 [R2-bgp]peer 3.3.3.3 next-hop-local [R2-ospf-1] default-route-advertise [R2-ospf-1]qui [R2]ip route 0.0.0.0 0.0.0.0 10.0.1.5
[R3]bgp 10 [R3-bgp]router-id 3.3.3.3 [R3-bgp] [R3-bgp]peer 10.0.1.9 as-num 40 [R3-bgp]peer 2.2.2.2 as-num %Aug 28 21:12:13:828 2012 R3 RM/3/RMLOG: BGP.: 10.0.1.9 State is changed from OPENCONFIRM to ESTABLISHED. 10 ^ % Unrecognized command found at '^' position. [R3-bgp]peer 2.2.2.2 as-num 10 [R3-bgp]peer 2.2.2.2 connect-int lo0 [R3-bgp]peer 2.2.2.2 next-hop-local [R3-bgp] %Aug 28 21:18:58:859 2012 R3 RM/3/RMLOG: BGP.: 2.2.2.2 State is changed from OPENCONFIRM to ESTABLISHED.
[R3-ospf-1]default-route-advertise [R3-ospf-1]qui [R3]ip rout 0.0.0.0 0.0.0.0 10.0.1.9 [R3]
R2上要配上一条指向外部的缺省静态路由,再配下发缺省的LSA,这样做当指向外部的链路down了,R2就不会下发缺省的LSA下去了 R3同样
EBGP 之间:R1和R2之间建立BGP邻居时如果用loopback接口,就需要配两个方向的静态路由,还要改TTL值,因为EBGP之间的默认TTL是1,即1跳 IBGP之间:R2和R3之间就不用这样,因为有IGP路由(OSPF)TTL值最大是255
为什么IBGP之间用loopback接口建立邻居,更可靠,防止物理端口down,物理端口down了就建立不起邻居了。而EBGP之间也可以用loopback接口,只是太麻烦了。
<R2>dis bgp rou
Total Number of Routes: 7
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 Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 10.0.1.5 0 0 30i *> 4.4.4.4/32 10.0.1.5 0 30 40i *> 10.0.1.0/30 10.0.1.5 0 0 30i * 10.0.1.4/30 10.0.1.5 0 0 30i * 10.0.1.8/30 10.0.1.5 0 30 40i *> 10.30.1.1/32 10.0.1.5 0 0 30i *> 10.40.4.1/32 10.0.1.5 0 30 40i
<R2>dis ip rout Routing Tables: Public Destinations : 22 Routes : 22
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 Static 60 0 10.0.1.5 Eth0/1/0 1.1.1.1/32 BGP 255 0 10.0.1.5 Eth0/1/0 2.2.2.2/32 Direct 0 0 127.0.0.1 InLoop0 3.3.3.3/32 OSPF 10 30 10.0.1.18 Eth0/1/2 4.4.4.4/32 BGP 255 0 10.0.1.5 Eth0/1/0 5.5.5.5/32 OSPF 10 10 10.0.1.18 Eth0/1/2 6.6.6.6/32 OSPF 10 20 10.0.1.18 Eth0/1/2 10.0.1.0/30 BGP 255 0 10.0.1.5 Eth0/1/0 10.0.1.4/30 Direct 0 0 10.0.1.6 Eth0/1/0 10.0.1.6/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.8/30 OSPF 10 40 10.0.1.18 Eth0/1/2 10.0.1.12/30 Direct 0 0 10.0.1.13 S0/2/0 10.0.1.13/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.14/32 Direct 0 0 10.0.1.14 S0/2/0 10.0.1.16/30 Direct 0 0 10.0.1.17 Eth0/1/2 10.0.1.17/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.20/30 OSPF 10 30 10.0.1.18 Eth0/1/2 10.0.1.24/30 OSPF 10 20 10.0.1.18 Eth0/1/2 10.30.1.1/32 BGP 255 0 10.0.1.5 Eth0/1/0 10.40.4.1/32 BGP 255 0 10.0.1.5 Eth0/1/0 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
<R2>tra -a 2.2.2.2 3.3.3.3 traceroute to 3.3.3.3(3.3.3.3) 30 hops max,40 bytes packet, press CTRL_C to break 1 10.0.1.18 4 ms 20 ms 15 ms 2 10.0.1.26 15 ms 10 ms 20 ms 3 3.3.3.3 30 ms 20 ms 10 ms
学会通过路由表分析,看是否有目标网段的路由,逐段排查。
<R5>dis ip rout Routing Tables: Public Destinations : 16 Routes : 16
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 O_ASE 150 1 10.0.1.17 Eth0/1/0 2.2.2.2/32 OSPF 10 10 10.0.1.17 Eth0/1/0 3.3.3.3/32 OSPF 10 20 10.0.1.26 Eth0/1/2 5.5.5.5/32 Direct 0 0 127.0.0.1 InLoop0 6.6.6.6/32 OSPF 10 10 10.0.1.26 Eth0/1/2 10.0.1.4/30 OSPF 10 20 10.0.1.17 Eth0/1/0 10.0.1.8/30 OSPF 10 30 10.0.1.26 Eth0/1/2 10.0.1.12/30 OSPF 10 1572 10.0.1.17 Eth0/1/0 10.0.1.16/30 Direct 0 0 10.0.1.18 Eth0/1/0 10.0.1.18/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.20/30 OSPF 10 20 10.0.1.26 Eth0/1/2 10.0.1.24/30 Direct 0 0 10.0.1.25 Eth0/1/2 10.0.1.25/32 Direct 0 0 127.0.0.1 InLoop0 10.10.5.1/32 Direct 0 0 127.0.0.1 InLoop0 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
[R6]dis ip rout Routing Tables: Public Destinations : 16 Routes : 16
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 O_ASE 150 1 10.0.1.21 Eth0/1/1 2.2.2.2/32 OSPF 10 20 10.0.1.25 Eth0/1/0 3.3.3.3/32 OSPF 10 10 10.0.1.21 Eth0/1/1 5.5.5.5/32 OSPF 10 10 10.0.1.25 Eth0/1/0 6.6.6.6/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.4/30 OSPF 10 30 10.0.1.25 Eth0/1/0 10.0.1.8/30 OSPF 10 20 10.0.1.21 Eth0/1/1 10.0.1.12/30 OSPF 10 1572 10.0.1.21 Eth0/1/1 10.0.1.16/30 OSPF 10 20 10.0.1.25 Eth0/1/0 10.0.1.20/30 Direct 0 0 10.0.1.22 Eth0/1/1 10.0.1.22/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.24/30 Direct 0 0 10.0.1.26 Eth0/1/0 10.0.1.26/32 Direct 0 0 127.0.0.1 InLoop0 10.10.6.1/32 Direct 0 0 127.0.0.1 InLoop0 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
注意R5,R6没有外部的明细路由,只有到外部的缺省路由,因为他们不是IBGP [R6] dis bgp rout [R6]
<R5> dis bgp rout <R5>
<R1>dis ip rout Routing Tables: Public Destinations : 11 Routes : 11
Destination/Mask Proto Pre Cost NextHop Interface
1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0 4.4.4.4/32 BGP 255 0 10.0.1.2 Eth0/1/2 10.0.1.0/30 Direct 0 0 10.0.1.1 Eth0/1/2 10.0.1.1/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.4/30 Direct 0 0 10.0.1.5 Eth0/1/0 10.0.1.5/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.8/30 BGP 255 0 10.0.1.2 Eth0/1/2 10.30.1.1/32 Direct 0 0 127.0.0.1 InLoop0 10.40.4.1/32 BGP 255 0 10.0.1.2 Eth0/1/2 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
<R1> dis bgp rout
Total Number of Routes: 10
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 Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 0.0.0.0 0 0 i *> 4.4.4.4/32 10.0.1.2 0 0 40i * 10.0.1.6 0 10 40i *> 10.0.1.0/30 0.0.0.0 0 0 i * 10.0.1.2 0 0 40i *> 10.0.1.4/30 0.0.0.0 0 0 i *> 10.0.1.8/30 10.0.1.2 0 0 40i *> 10.30.1.1/32 0.0.0.0 0 0 i *> 10.40.4.1/32 10.0.1.2 0 0 40i * 10.0.1.6 0 10 40i
R1到4.4.4.4的路由选择下一跳是10.0.1.2是由于开销
<R2>dis ip rout Routing Tables: Public Destinations : 23 Routes : 23
Destination/Mask Proto Pre Cost NextHop Interface
0.0.0.0/0 Static 60 0 10.0.1.5 Eth0/1/0 1.1.1.1/32 BGP 255 0 10.0.1.5 Eth0/1/0 2.2.2.2/32 Direct 0 0 127.0.0.1 InLoop0 3.3.3.3/32 OSPF 10 30 10.0.1.18 Eth0/1/2 4.4.4.4/32 BGP 255 0 3.3.3.3 Eth0/1/2 5.5.5.5/32 OSPF 10 10 10.0.1.18 Eth0/1/2 6.6.6.6/32 OSPF 10 20 10.0.1.18 Eth0/1/2 10.0.1.0/30 BGP 255 0 10.0.1.5 Eth0/1/0 10.0.1.4/30 Direct 0 0 10.0.1.6 Eth0/1/0 10.0.1.6/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.8/30 OSPF 10 40 10.0.1.18 Eth0/1/2 10.0.1.12/30 Direct 0 0 10.0.1.13 S0/2/0 10.0.1.13/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.14/32 Direct 0 0 10.0.1.14 S0/2/0 10.0.1.16/30 Direct 0 0 10.0.1.17 Eth0/1/2 10.0.1.17/32 Direct 0 0 127.0.0.1 InLoop0 10.0.1.20/30 OSPF 10 30 10.0.1.18 Eth0/1/2 10.0.1.24/30 OSPF 10 20 10.0.1.18 Eth0/1/2 10.10.6.1/32 OSPF 10 20 10.0.1.18 Eth0/1/2 10.30.1.1/32 BGP 255 0 10.0.1.5 Eth0/1/0 10.40.4.1/32 BGP 255 0 3.3.3.3 Eth0/1/2 127.0.0.0/8 Direct 0 0 127.0.0.1 InLoop0 127.0.0.1/32 Direct 0 0 127.0.0.1 InLoop0
<R2>dis bgp rout
Total Number of Routes: 10
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 Network NextHop MED LocPrf PrefVal Path/Ogn
*> 1.1.1.1/32 10.0.1.5 0 0 30i *>i 4.4.4.4/32 3.3.3.3 0 100 0 40i * 10.0.1.5 0 30 40i *> 10.0.1.0/30 10.0.1.5 0 0 30i * i 3.3.3.3 0 100 0 40i * 10.0.1.4/30 10.0.1.5 0 0 30i * 10.0.1.8/30 10.0.1.5 0 30 40i *> 10.30.1.1/32 10.0.1.5 0 0 30i *>i 10.40.4.1/32 3.3.3.3 0 100 0 40i * 10.0.1.5 0 30 40i |