EqLlyHJ5w6,694hQRgLWm
华三实验大全之BGP篇华三实验大全之BGP篇 实验目录: 1.BGP基本实验 2.非等级负载分担 3.LOCAL_PREF属性 实现离开本地AS时的最佳路由 4.MED属性 实现进入AS时的最佳路径 5.Prefered-value(首选值)属性 6.BGP反射 7.同步 实验拓扑: 1.EBGP对等体之间的基本配置 [R1]bgp 10 [R1-bgp]router-id 1.1.1.1 [R1-bgp]peer 192.168.1.2 as-number 20 [R1-bgp]peer 192.168.4.1 as-number 20(没用到) [R1-bgp]net 1.1.1.1 32 [R1-bgp]q [R2]bgp 20 [R2-bgp]router-id 2.2.2.2 [R2-bgp]peer 192.168.1.1 as-number 10 [R2-bgp]network 2.2.2.2 32 2.建立邻居关系必须要求tcp可达,ospf宣告直连网段 [R2]ospf [R2-ospf-1]area 0 [R2-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255 [R2-ospf-1-area-0.0.0.0]q [R2-ospf-1]q [R3]ospf [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]q [R3-ospf-1]q [R4]ospf [R4-ospf-1]area 0 [R4-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255 [R4-ospf-1-area-0.0.0.0]q [R4-ospf-1]q 3.R2和R3是建立邻居关系 [R2-bgp]peer 192.168.2.2 as-number 20 [R3]bgp 20 [R3-bgp]router-id 3.3.3.3 [R3-bgp]peer 192.168.2.1 as-number 20 [R3-bgp]network 3.3.3.3 32 [R2-bgp]display bgp routing-table Total Number of Routes: 3 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 192.168.1.1 0 0 10i *> 2.2.2.2/32 0.0.0.0 0 0 i *>i 3.3.3.3/32 192.168.2.2 0 100 0 i *代表有效路由 >代表最有路由 [R3-bgp]display bgp routing-table Total Number of Routes: 3 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 Network NextHop MED LocPrf PrefVal Path/Ogn i 1.1.1.1/32 192.168.1.1 0 100 0 10i *>i 2.2.2.2/32 192.168.2.1 0 100 0 i *> 3.3.3.3/32 0.0.0.0 0 0 i 关于到1.1.1。1的无效我们下面讲 4.R3和R4开启邻居关系 [R3-bgp]peer 192.168.3.2 as-number 20 [R4-bgp]peer 192.168.3.1 as-number 20 R2上学不到R4的4.4.4.4,同样R4也学不到R2的路由 [R3-bgp]display bgp routing-table Total Number of Routes: 3 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 Network NextHop MED LocPrf PrefVal Path/Ogn i 1.1.1.1/32 192.168.1.1 0 100 0 10i *>i 2.2.2.2/32 192.168.2.1 0 100 0 i *> 3.3.3.3/32 0.0.0.0 0 0 i 上面可以看到,R3已经有到1.1.1.1、2.2.2.2网络的路由,R3不会发给R4吗?? 看R4的,答案是没有把路由信息发给R4。 原因是:BGP遵循AS_PATH属性。 AS_PATH属性是公认比遵循属性。该属性主要解决环路问题,BGP发言者从IBGP获得的路由不向它的IBGP对等实体发送! [R4-bgp]display bgp routing-table Total Number of Routes: 1 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 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 3.3.3.3/32 192.168.3.1 0 100 0 i 5.我们要创建全连接 [R2]bgp 20 [R2-bgp]peer 192.168.3.2 as-number 20 [R4]bgp 20 [R4-bgp]peer 192.168.2.1 as-number 20 查看到1.1.1.1的路由不是有效的,我们下面解决 [R4-bgp]display bgp routing-table Total Number of Routes: 3 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 Network NextHop MED LocPrf PrefVal Path/Ogn i 1.1.1.1/32 192.168.1.1 0 100 0 10i *>i 2.2.2.2/32 192.168.2.1 0 100 0 i *>i 3.3.3.3/32 192.168.3.1 0 100 0 i 从上面的输出可以看出,R4到1.1.1.1不是有效的,是因为下一跳是192.168.1.1的原因 R4根本就不知道到达192.168.1.1的路径! 出现的最终原因是什么呢? 答案:NEXT_HOP属性。NEXT_HOP也是公认比遵循属性。 下面是NEXT_HOP的四个特性! 1.BGP发言者把自己产生的路由发给所有邻居时,将把改路由信息的下一跳属性修改他们直连的网段。像R4学到R3的路由,下一跳就是192.168.3.1。 2.BGP发言者把从EBGP邻居得到的路由发给IBGP邻居时,并不改变该路由信息的下一跳属性,将从EBGP得到的路由的NEXT_HOP直接传递给IBGP对等体。像R3从R2学到R1路由,下一跳是192.168.1.1。 3.当内部的发给外部的就不是上面的那样的,下一跳会是他们直连的网段。像R1从R2学到R3路由,下一跳是192.168.1.2。 解决方法是配置R2 [R2]bgp 20 [R2-bgp]peer 192.168.3.2 next-hop-local 此时在查看R4到R1的路由为有效了 [R4-bgp]display bgp routing-table Total Number of Routes: 3 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 Network NextHop MED LocPrf PrefVal Path/Ogn *>i 1.1.1.1/32 192.168.2.1 0 100 0 10i *>i 2.2.2.2/32 192.168.2.1 0 100 0 i *>i 3.3.3.3/32 192.168.3.1 0 100 0 i 为什么下一跳就是192.168.2.1而不是192.168.3.1呢? 因为R1的路由信息是从R2传到R4的(逻辑上的bgp邻居) 查看一下R3的bgp路由 [R3]display bgp routing-table Total Number of Routes: 3 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 Network NextHop MED LocPrf PrefVal Path/Ogn i 1.1.1.1/32 192.168.1.1 0 100 0 10i *>i 2.2.2.2/32 192.168.2.1 0 100 0 i *> 3.3.3.3/32 0.0.0.0 0 0 i 同样是不可达的,我们怎样解决呢?同上啊!原理一样! [R2]bgp 20 [R2-bgp]peer 192.168.2.2 next-hop-local 6.此时我们宣告一下4.4.4.4 32网络,查看所有的bgp路由情况 R1的到所有的都有效、最优 <R1>display bgp routing-table Total Number of Routes: 4 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 *> 2.2.2.2/32 192.168.1.2 0 0 20i *> 3.3.3.3/32 192.168.1.2 0 20i *> 4.4.4.4/32 192.168.1.2 0 20i 并且加上源地址能ping同。为什么不加源地址不行呢? 原因是R1不是知道as20内的直连网络,在ping的时候没有可以匹配的路由,数据包丢弃 <R1>ping -a 1.1.1.1 4.4.4.4 PING 4.4.4.4: 56 data bytes, press CTRL_C to break Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=253 time=34 ms Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=253 time=20 ms Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=253 time=10 ms Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=253 time=1 ms Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=253 time=20 ms --- 4.4.4.4 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/17/34 ms [R4]ping -a 4.4.4.4 1.1.1.1 PING 1.1.1.1: 56 data bytes, press CTRL_C to break Reply from 1.1.1.1: bytes=56 Sequence=1 ttl=253 time=35 ms Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=253 time=20 ms Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=253 time=20 ms Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=253 time=1 ms Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=253 time=1 ms --- 1.1.1.1 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/15/35 ms 6.怎样才能不加源地址呢? 引进直连路由 [R1]bgp 10 [R1-bgp]import-route direct [R2]bgp 20 [R2-bgp]import-route direct 此时查看一下R1的路由 [R1]display ip routing-table Routing Tables: Public Destinations : 14 Routes : 14 Destination/Mask Proto Pre Cost NextHop Interface 1.1.1.1/32 Direct 0 0 127.0.0.1 InLoop0 2.2.2.2/32 BGP 255 0 192.168.1.2 S0/2/0 3.3.3.3/32 BGP 255 0 192.168.1.2 S0/2/0 4.4.4.4/32 BGP 255 0 192.168.1.2 S0/2/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 192.168.1.0/24 Direct 0 0 192.168.1.1 S0/2/0 192.168.1.1/32 Direct 0 0 127.0.0.1 InLoop0 192.168.1.2/32 Direct 0 0 192.168.1.2 S0/2/0 192.168.2.0/24 BGP 255 0 192.168.1.2 S0/2/0 192.168.2.2/32 BGP 255 0 192.168.1.2 S0/2/0 192.168.4.0/24 Direct 0 0 192.168.4.2 S0/2/1 192.168.4.1/32 Direct 0 0 192.168.4.1 S0/2/1 192.168.4.2/32 Direct 0 0 127.0.0.1 InLoop0 [R1]ping 4.4.4.4 PING 4.4.4.4: 56 data bytes, press CTRL_C to break Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=253 time=15 ms Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=253 time=1 ms Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=253 time=10 ms Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=253 time=10 ms Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=253 time=20 ms --- 4.4.4.4 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/11/20 ms 当R4 ping 1.1.1.1时怎么ping不通呢? 因为数据包过去了,没有回来! 当R4发的ping包到源地址是192.168.3.2目的地址1.1.1.1达R1后,R1做出回应。ping包的源地址1.1.1.1目的地址为192.168.3.2,而R1的路由表里没有,所以丢弃 [R4]ping 1.1.1.1 PING 1.1.1.1: 56 data bytes, press CTRL_C to break Request time out Request time out Request time out Request time out Request time out --- 1.1.1.1 ping statistics --- 5 packet(s) transmitted 0 packet(s) received 100.00% packet loss 要想直接ping同。可以在R3或者R4上引入直连的,只要让R1学的到到192.168.3.2的路由便可以 [R3]bgp 20 [R3-bgp]import-route direct 配置BGP基本实验结束 二.非等级负载分担 实验拓扑: 在实验一得基础上添加了R1与R4之间的邻居关系 从R1查看到R3的路由,发现到3.3.3.3走的R2。 实现负载分担的命令是: [R1]bgp 10 [R1-bgp]balance 2 /默认是1 从上面可以看出R1到3.3.3.3实现了负载! 三.LOCAL_PREF属性 简介: 实现选择离开本地AS时的最佳路径 会影响本as区域内的选路,当本区域到达某个目的网段有多个路径时,可以配置local_pref属性来影响选路! 数值越大越优先 实验拓扑: 现在查看R3到1.1.1.1走的是R2即:R3-----R2-----R1 我们做下修改。让R3到R1的路径走: R3----R4----R1 [R4]bgp 20 [R4-bgp]default local-preference ? INTEGER<0-4294967295> Specify a local preference [R4-bgp]default local-preference 200 四.MED属性 简介: 实现进入AS时的最佳路径 MED用于EBGP邻居有多条路径到达本AS的情况,用途是告诉EBGP邻居进入本AS的较优先路径! 数值越小越优先 实验拓扑: 修改R2的med值 [R2]bgp 20 [R2-bgp]default med ? INTEGER<0-4294967295> MED value [R2-bgp]default med 2 五.Prefered-value(首选值)属性 简介: 首选值为私有BGP属性,通过为从不同对等体接受到的路由分配不同的首选值。 越大越好! 六.BGP反射 实验人:高承旺 实验名称:BGP反射 实验拓扑: 实验步骤 R1与R2建立邻居关系 [R1]bgp 10 [R1-bgp]router-id 1.1.1.1 [R1-bgp]peer 192.168.1.2 as-number 20 [R1-bgp]net 1.1.1.1 32 [R1-bgp]q [R2]bgp 20 [R2-bgp]peer 192.168.1.1 as-number 10 [R2-bgp]router-id 2.2.2.2 [R2-bgp]net 2.2.2.2 32 [R2-bgp]q 开启ospf [R2]ospf [R2-ospf-1]area 0 [R2-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255 [R3]ospf [R3-ospf-1]area 0 [R3-ospf-1-area-0.0.0.0]net 192.168.2.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255 [R3-ospf-1-area-0.0.0.0]q [R3-ospf-1]q [R4]ospf [R4-ospf-1]area 0 [R4-ospf-1-area-0.0.0.0]net 192.168.3.0 0.0.0.255 [R4-ospf-1-area-0.0.0.0]q [R4-ospf-1]q IBGP邻居建立 R2----R3---R4 R2和R4之间不建立邻居 [R2]bgp 20 [R2-bgp]peer 192.168.2.2 as-number 20 [R2-bgp]q [R3]bgp 20 [R3-bgp]peer 192.168.2.1 as-number 20 [R3-bgp]peer 192.168.3.2 as-number 20 [R3-bgp]q [R3]bgp 20 [R3-bgp]router-id 3.3.3.3 [R3-bgp]net 3.3.3.3 32 [R4]bgp 20 [R4-bgp]router-id 4.4.4.4 [R4-bgp]peer 192.168.3.1 as-n [R4-bgp]peer 192.168.3.1 as-number 20 [R4-bgp]network 4.4.4.4 32 到1.1.1.1的不是有效最优的 [R3]display bgp routing-table Total Number of Routes: 4 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 Network NextHop MED LocPrf PrefVal Path/Ogn i 1.1.1.1/32 192.168.1.1 0 100 0 10i *>i 2.2.2.2/32 192.168.2.1 0 100 0 i *> 3.3.3.3/32 0.0.0.0 0 0 i *>i 4.4.4.4/32 192.168.3.2 0 100 0 i [R2-bgp]peer 192.168.2.2 next-hop-local 开启反射 [R3]bgp 20 [R3-bgp]peer 192.168.2.1 reflect-client [R3-bgp]peer 192.168.3.2 reflect-client [R2]display bgp routing-table Total Number of Routes: 4 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 192.168.1.1 0 0 10i *> 2.2.2.2/32 0.0.0.0 0 0 i *>i 3.3.3.3/32 192.168.2.2 0 100 0 i i 4.4.4.4/32 192.168.3.2 0 100 0 i 虽然邻居创建好了,但是是不能通信的,因为BGP不知道到192。168.3.0的网段! 让BGP知道知道192.168.3.0网络 [R3]bgp 20 [R3-bgp]net 192.168.3.0 24 <R1>display bgp routing-table Total Number of Routes: 5 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 *> 2.2.2.2/32 192.168.1.2 0 0 20i *> 3.3.3.3/32 192.168.1.2 0 20i *> 4.4.4.4/32 192.168.1.2 0 20i *> 192.168.3.0 192.168.1.2 0 20i [R1]ping -a 1.1.1.1 4.4.4.4 PING 4.4.4.4: 56 data bytes, press CTRL_C to break Reply from 4.4.4.4: bytes=56 Sequence=1 ttl=253 time=15 ms Reply from 4.4.4.4: bytes=56 Sequence=2 ttl=253 time=20 ms Reply from 4.4.4.4: bytes=56 Sequence=3 ttl=253 time=1 ms Reply from 4.4.4.4: bytes=56 Sequence=4 ttl=253 time=20 ms Reply from 4.4.4.4: bytes=56 Sequence=5 ttl=253 time=20 ms --- 4.4.4.4 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/15/20 ms 七.BGP同步 简介: 开启同步,内网必须要知道到外网as的网段 实验拓扑:在实验六的基础上! 邻居建立: 取消上面实验的IBGP邻居关系 R2-----R4创建邻居关系。 R3不与R2、R4创建邻居关系 [R2]bgp 20 [R2-bgp]peer 192.168.3.2 as-number 20 [R4]bgp 20 [R4-bgp]peer 192.168.2.1 as-number 20 [R4-bgp]peer 192.168.4.2 as-number 30 [R5]bgp 30 [R5-bgp]router-id 5.5.5.5 [R5-bgp]peer 192.168.4.1 as-number 20 [R5-bgp]net 5.5.5.5 32 [R5-bgp]q [R2]bgp 20 [R2-bgp]peer 192.168.3.2 next-hop-local [R4]bgp 20 [R4-bgp]peer 192.168.2.1 next-hop-local <R1>display bgp routing-table Total Number of Routes: 4 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 *> 2.2.2.2/32 192.168.1.2 0 0 20i *> 4.4.4.4/32 192.168.1.2 0 20i *> 5.5.5.5/32 192.168.1.2 0 20 30i [R5]display bgp routing-table Total Number of Routes: 4 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 Network NextHop MED LocPrf PrefVal Path/Ogn *> 1.1.1.1/32 192.168.4.1 0 20 10i *> 2.2.2.2/32 192.168.4.1 0 20i *> 4.4.4.4/32 192.168.4.1 0 0 20i *> 5.5.5.5/32 0.0.0.0 0 0 i 上面输出表面所有的邻居已经创建成功! 我们开启R2和R4的同步 [R2]bgp 20 [R2-bgp]synchronization [R4]bgp 20 [R4-bgp]synchronization [R4-bgp]q <R1>display bgp routing-table Total Number of Routes: 2 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 *> 2.2.2.2/32 192.168.1.2 0 0 20i 开启后邻居关系变了,原因是内部网络不知道到达外网AS的网段 总之:开启同步,内网必须要知道到外网as的网段 做法有很多种。只要内部的有到外部的网段就行! 我们以用ospf引进bgp路由来学习外网网段 [R2]ospf [R2-ospf-1]import-route bgp [R4]ospf [R4-ospf-1]import-route bgp <R1>display bgp routing-table Total Number of Routes: 3 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 *> 2.2.2.2/32 192.168.1.2 0 0 20i *> 5.5.5.5/32 192.168.1.2 0 20 30i <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=34 ms Reply from 5.5.5.5: bytes=56 Sequence=2 ttl=252 time=1 ms Reply from 5.5.5.5: bytes=56 Sequence=3 ttl=252 time=1 ms Reply from 5.5.5.5: bytes=56 Sequence=4 ttl=252 time=1 ms Reply from 5.5.5.5: bytes=56 Sequence=5 ttl=252 time=10 ms --- 5.5.5.5 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 1/9/34 ms
|