BGP小实验——选路不困难,只要有方法

  • 前言
  • 一、需求
  • 二、命令
    • 1、先配置基础命令,完成全网通
      • R1
      • R2
      • R3
      • R4
      • R5
    • 2、查看BGP路由表
      • R1
      • R4
    • 3、择路(我们用两种方式)
      • R1
      • R3
    • 4、刷新下BGP,再次查看择路结果
      • R1
      • R4
      • 5、结论

前言

一、需求

  • 全网通
  • R1到R4走R3
  • R4到R1走R3

二、命令

1、先配置基础命令,完成全网通

R1

<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[Huawei-GigabitEthernet0/0/1]int loop 0
[Huawei-LoopBack0]ip add 1.1.1.1 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 2.2.2.2 32 12.0.0.2
[Huawei]ip route-static 3.3.3.3 32 13.0.0.3
[Huawei]bgp 100
[Huawei-bgp]router-id 1.1.1.1
[Huawei-bgp]peer 2.2.2.2 as-number 200
[Huawei-bgp]peer 3.3.3.3 as-number 200
[Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[Huawei-bgp]peer 2.2.2.2 ebgp-max-hop 2
[Huawei-bgp]peer 3.3.3.3 ebgp-max-hop 2
[Huawei-bgp]net 1.1.1.1 32
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]q
[Huawei]ping -a 1.1.1.1 5.5.5.5PING 5.5.5.5: 56  data bytes, press CTRL_C to breakReply from 5.5.5.5: bytes=56 Sequence=1 ttl=253 time=30 msReply from 5.5.5.5: bytes=56 Sequence=2 ttl=253 time=20 msReply from 5.5.5.5: bytes=56 Sequence=3 ttl=253 time=30 msReply from 5.5.5.5: bytes=56 Sequence=4 ttl=253 time=40 msReply from 5.5.5.5: bytes=56 Sequence=5 ttl=253 time=30 ms--- 5.5.5.5 ping statistics ---5 packet(s) transmitted5 packet(s) received0.00% packet lossround-trip min/avg/max = 20/30/40 ms

R2

<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 24.0.0.2 24
[Huawei-GigabitEthernet0/0/1]int loop0
[Huawei-LoopBack0]ip add 2.2.2.2 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 1.1.1.1 32 12.0.0.1
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net 2.2.2.2 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]net 24.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
[Huawei]bgp 200
[Huawei-bgp]router-id 2.2.2.2
[Huawei-bgp]peer 1.1.1.1 as-number 100
[Huawei-bgp]peer 4.4.4.4 as-number 200
[Huawei-bgp]peer 3.3.3.3 as-number 200
[Huawei-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[Huawei-bgp]peer 1.1.1.1 ebgp-max-hop 2
[Huawei-bgp]peer 3.3.3.3 next-hop-local
[Huawei-bgp]peer 4.4.4.4 next-hop-local
[Huawei-bgp]net 1.1.1.1 32
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]net 4.4.4.4 32

R3

<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 13.0.0.3 24
[Huawei-GigabitEthernet0/0/1]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 34.0.0.3 24
[Huawei-GigabitEthernet0/0/0]int loop0
[Huawei-LoopBack0]ip add 3.3.3.3 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 1.1.1.1 32 13.0.0.1
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net 3.3.3.3 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]net 34.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
[Huawei]bgp 200
[Huawei-bgp]router-id 3.3.3.3
[Huawei-bgp]peer 1.1.1.1 as-number 100
[Huawei-bgp]peer 4.4.4.4 as-number 200
[Huawei-bgp]peer 2.2.2.2 as-number 200
[Huawei-bgp]peer 1.1.1.1 connect-interface LoopBack 0
[Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[Huawei-bgp]peer 1.1.1.1 ebgp-max-hop 2
[Huawei-bgp]peer 4.4.4.4 next-hop-local
[Huawei-bgp]peer 2.2.2.2 next-hop-local
[Huawei-bgp]net 1.1.1.1 32
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]net 4.4.4.4 32

R4

<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip add 34.0.0.4 24
[Huawei-GigabitEthernet0/0/0]int g0/0/1
[Huawei-GigabitEthernet0/0/1]ip add 24.0.0.4 24
[Huawei-GigabitEthernet0/0/1]int g0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 45.0.0.4 24
[Huawei-GigabitEthernet0/0/2]int loop0
[Huawei-LoopBack0]ip add 4.4.4.4 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 5.5.5.5 32 45.0.0.5
[Huawei]ospf
[Huawei-ospf-1]area 0
[Huawei-ospf-1-area-0.0.0.0]net 4.4.4.4 0.0.0.0
[Huawei-ospf-1-area-0.0.0.0]net 34.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]net 24.0.0.0 0.0.0.255
[Huawei-ospf-1-area-0.0.0.0]q
[Huawei-ospf-1]q
[Huawei]bgp 200
[Huawei-bgp]router-id 4.4.4.4
[Huawei-bgp]peer 2.2.2.2 as-number 200
[Huawei-bgp]peer 3.3.3.3 as-number 200
[Huawei-bgp]peer 5.5.5.5 as-number 300
[Huawei-bgp]peer 2.2.2.2 connect-interface LoopBack 0
[Huawei-bgp]peer 3.3.3.3 connect-interface LoopBack 0
[Huawei-bgp]peer 5.5.5.5 connect-interface LoopBack 0
[Huawei-bgp]peer 2.2.2.2 next-hop-local
[Huawei-bgp]peer 3.3.3.3 next-hop-local
[Huawei-bgp]peer 5.5.5.5 ebgp-max-hop 2
[Huawei-bgp]net 2.2.2.2 32
[Huawei-bgp]net 3.3.3.3 32
[Huawei-bgp]net 4.4.4.4 32
[Huawei-bgp]net 5.5.5.5 32

R5

<Huawei>u t m
Info: Current terminal monitor is off.
<Huawei>sys
Enter system view, return user view with Ctrl+Z.
[Huawei]int g 0/0/2
[Huawei-GigabitEthernet0/0/2]ip add 45.0.0.5 24
[Huawei-GigabitEthernet0/0/2]int loop0
[Huawei-LoopBack0]ip add 5.5.5.5 32
[Huawei-LoopBack0]q
[Huawei]ip route-static 4.4.4.4 32 45.0.0.4
[Huawei]bgp 300
[Huawei-bgp]router-id 5.5.5.5
[Huawei-bgp]peer 4.4.4.4 as-number 200
[Huawei-bgp]peer 4.4.4.4 connect-interface LoopBack 0
[Huawei-bgp]peer 4.4.4.4 ebgp-max-hop 2
[Huawei-bgp]net 4.4.4.4 32
[Huawei-bgp]net 5.5.5.5 32

2、查看BGP路由表

R1

[Huawei]dis 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 - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 13Network            NextHop        MED        LocPrf    PrefVal Path/Ogn*>   1.1.1.1/32         0.0.0.0         0                     0      i*                       2.2.2.2         0                     0      200i*                       3.3.3.3         0                     0      200i*>   2.2.2.2/32         0.0.0.0         0                     0      i*                       3.3.3.3         2                     0      200i2.2.2.2         0                     0      200i*>   3.3.3.3/32         0.0.0.0         0                     0      i*                       2.2.2.2         2                     0      200i3.3.3.3         0                     0      200i*>   4.4.4.4/32         2.2.2.2         1                     0      200i*                       3.3.3.3         1                     0      200i*>   5.5.5.5/32         2.2.2.2                               0      200i*                       3.3.3.3                               0      200i

R4

[Huawei]dis 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 - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 14Network            NextHop        MED        LocPrf    PrefVal Path/Ogn*>i  1.1.1.1/32         2.2.2.2         0          100        0      i* i                     3.3.3.3         0          100        0      i*>   2.2.2.2/32         0.0.0.0         1                     0      i* i                     3.3.3.3         2          100        0      ii                     2.2.2.2         0          100        0      i*>   3.3.3.3/32         0.0.0.0         1                     0      i* i                     2.2.2.2         2          100        0      ii                     3.3.3.3         0          100        0      i*>   4.4.4.4/32         0.0.0.0         0                     0      i* i                     2.2.2.2         1          100        0      i* i                     3.3.3.3         1          100        0      i*                       5.5.5.5         0                     0      300i*>   5.5.5.5/32         0.0.0.0         0                     0      i5.5.5.5         0                     0      300i

这时候,我们可以看到,从R1到R4走的是R2,R4到R1走的也是R2,我们需要择路。

3、择路(我们用两种方式)

R1

[Huawei]route-policy as permit node 10
Info: New Sequence of this List.
[Huawei-route-policy]apply as-path 123 123 additive
[Huawei-route-policy]q
[Huawei]bgp 100
[Huawei-bgp]peer 2.2.2.2 route-policy as import
[Huawei-bgp]q
[Huawei]q
<Huawei>refresh bgp all import

R3

[Huawei]route-policy lop permit node 10
Info: New Sequence of this List.
[Huawei-route-policy]apply local-preference 222
[Huawei-route-policy]q
[Huawei]bgp 200
[Huawei-bgp]peer 4.4.4.4 route-policy lop export
[Huawei-bgp]q
[Huawei]q
<Huawei>refresh bgp all export

4、刷新下BGP,再次查看择路结果

R1

<Huawei>dis 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 - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 13Network            NextHop        MED        LocPrf    PrefVal Path/Ogn*>   1.1.1.1/32         0.0.0.0         0                     0      i*                       3.3.3.3         0                     0      200i*                       2.2.2.2         0                     0      123 123 20
0i*>   2.2.2.2/32         0.0.0.0         0                     0      i*                       3.3.3.3         2                     0      200i2.2.2.2         0                     0      123 123 20
0i*>   3.3.3.3/32         0.0.0.0         0                     0      i*                       2.2.2.2         2                     0      123 123 20
0i3.3.3.3         0                     0      200i*>   4.4.4.4/32         3.3.3.3         1                     0      200i*                       2.2.2.2         1                     0      123 123 20
0i*>   5.5.5.5/32         3.3.3.3                               0      200i*                       2.2.2.2                               0      123 123 20
0i

R4

[Huawei]dis bgp routing-tableBGP Local router ID is 4.4.4.4 Status codes: * - valid, > - best, d - damped,h - history,  i - internal, s - suppressed, S - StaleOrigin : i - IGP, e - EGP, ? - incompleteTotal Number of Routes: 14Network            NextHop        MED        LocPrf    PrefVal Path/Ogn*>i  1.1.1.1/32         3.3.3.3         0          222        0      i* i                     2.2.2.2         0          100        0      i*>i  2.2.2.2/32         3.3.3.3         2          222        0      i*                       0.0.0.0         1                     0      ii                     2.2.2.2         0          100        0      i*>   3.3.3.3/32         0.0.0.0         1                     0      i* i                     2.2.2.2         2          100        0      ii                     3.3.3.3         0          222        0      i*>i  4.4.4.4/32         3.3.3.3         1          222        0      i*                       0.0.0.0         0                     0      i* i                     2.2.2.2         1          100        0      i*                       5.5.5.5         0                     0      300i*>   5.5.5.5/32         0.0.0.0         0                     0      i5.5.5.5         0                     0      300i

5、结论

  • 我们可以看到,我们改变了R3的local-preference为222之后,优先级大于R2,然后对D4执行了出站export策略,所以R4到R1的时候选择了R3。
  • 我们在R1对R2执行了入站import策略,对R2已有的AS-path基础上追加了123和123,使得优先级低于R3,这样,从R1到R4是,自然而然的选择了R2这条线。

BGP小实验——选路不困难,只要有方法相关推荐

  1. BGP小实验(二)——还是他,继续第二波走起来

    BGP小实验(二)--还是他,继续第二波走起来 前言 一.需求(还用得着说么) 二.命令 1.基础配置走起 R1 R2 R3 R4 R5 2.BGP走起来 R1 R2 R3 R4 R5 总结 前言 一 ...

  2. BGP小实验(一)——小实验练练手走起来

    BGP小实验(一)--小实验练练手走起来 前言 一.需求 二.命令 1.基础配置走起来(端口+回环口IP,RIP及OSPF) R1 R2 R3 R4 R5 R6 R7 2.BGP走起来 R1 R2 R ...

  3. 亮灯泡科技php,记科学小实验《灯泡亮了》

    楼盘推广启动沙漏多米诺启动仪式激光船舵专业销售,庆典启动沙漏,开业活动沙漏,发布会多米诺启动仪式,诺骨牌由300个块骨牌组成,也就是说由300多幅画面 组成,一般制作时间要3-4天这样,多米诺启动仪式 ...

  4. 这次来个BGP反射器的简单小实验

    这次来个BGP反射器的简单小实验 前言 一.先把端口简单配置写完(OSPF.RIP.IP) R1 R2 R3 R4 R5 R6 R7 R8 二.配置BGP及反射器 R1 R2 R3 R4 R5 R6 ...

  5. [na]出口选路pbr小实验视频

    什么是策略路由? 一般都是部署在出口路由器,用于路径强制分发的, 优先级高于路由表. 策略路由小实验视频 这个是读书时候录的一个策略路由小实验 转载于:https://www.cnblogs.com/ ...

  6. 路由协议(OSPF、ISIS、BGP)实验配置

    目录 OSPF基础实验 建立OSPF邻居 配置区域认证 配置虚连接 配置接口的网络类型 配置特殊区域 配置路由选路 配置路由过滤 ISIS基础实验配置 配置ISIS邻居建立 配置认证 配置路由扩散 配 ...

  7. 三人表决器_数电小实验之三人表决器

    数电小实验 20级会员们的模电实验已经结束了,他们的培训计划已经从模电实验进行到了数电实验.他们将学习到一个新的知识--逻辑电路. 接下来让我们一起深入了解本次任务吧! 实验:三人表决器的设计和搭建 ...

  8. 配置OSPF实现pc机互通小实验

    配置OSPF实现pc机互通小实验 ** 前言:ospf是什么 OSPF(Open Shortest Path First开放式最短路径优先)是一个内部网关协议(Interior Gateway Pro ...

  9. BGP属性即选路规则

    BGP属性即选路规则 文章目录 BGP属性即选路规则 BGP属性 1.Origin(起源属性) 2.AS-Path属性 3.next-hop(下一跳属性) 4.local-preference(本地优 ...

最新文章

  1. Hive代码组织及架构简单介绍
  2. 最直接的解决服务器宕机的方法
  3. javascript设计模式系列 - LukeLin - 博客园
  4. 【转】Azure Logic App Demo
  5. Anaconda如何重新在开始菜单显示
  6. 苹果Mac 3D 建模渲染软件:Vectorworks
  7. HFSS19 官方中文教程系列 L03
  8. tcp 测试工具 android,安卓版手机tcp调试助手
  9. 第七讲:工业网络——PST软件使用及web配置
  10. chrome python插件,珍藏版Chrome插件送给你们,不仅是程序员必备
  11. python列表元组字典
  12. 如何在Linux系统下更改系统语言?
  13. 【办公软件有哪几种】万彩办公大师教程丨Office转图片工具
  14. uart口图片_串口(USART)框图的讲解
  15. 武汉2022专技公需课必修答案
  16. Redis爬坑记(一):incr命令和expire命令的误区
  17. 2022年软考可以参加哪些科目考试?熟知
  18. 有关关键路径的概念和算法
  19. 中心极限定理-通俗理解
  20. 【无标题】ssh登陆 提示 session ended very soon

热门文章

  1. 【全真互联网下音视频技术创新应用】
  2. LiveVideoStackCon 北京站,好久不见
  3. 音视频技术开发周刊 | 154
  4. H.264基础知识及视频码流解析
  5. 《Go语言圣经》学习笔记 第六章 方法
  6. 腾讯极客挑战赛正式开赛!「鹅罗斯方块」开“玩”啦
  7. Syslog系统日志配置
  8. va_list/va_start/va_arg/va_end深入分析
  9. OpenStack Gluon
  10. leetcode 756. Pyramid Transition Matrix | 756. 金字塔转换矩阵(BFS)