• 首页 首页 icon
  • 工具库 工具库 icon
    • IP查询 IP查询 icon
  • 内容库 内容库 icon
    • 快讯库 快讯库 icon
    • 精品库 精品库 icon
    • 问答库 问答库 icon
  • 更多 更多 icon
    • 服务条款 服务条款 icon

网络路由

武飞扬头像
Junzeng_Kai
帮助2

1. 路由器

        路由器工作在三层,每个接口都处于不用的网段中,即不同的广播域。但大多情况下,两台路由器直接相连的接口是同一个广播域,即一个网段。

        路由器具有判断网络地址和选择路径的功能,能在多网络互联的环境中,建立灵活的连接,可用完全不同的数据分组和介质访问方法连接各种子网。

        路由器属于网络层的设备,有隔离广播域的作用,它的每个端口都是一个独立的广播域,也是一个单独的冲突域。

2. 路由

        通俗地说,去往目标的路径。网络中是指导IP报文转发的路径信息。

3. 路由表

        路由的信息都放在路由表当中,就是帮助路由进行选路用的,是路由器或者三层交换机或者具备三层功能防火墙用于指导IP报文的转发。

        查看路由的命令

  1.  
    <AR3>display ip routing-table
  2.  
    Route Flags: R - relay, D - download to fib
  3.  
    ------------------------------------------------------------------------------
  4.  
    Routing Tables: Public
  5.  
    Destinations : 7 Routes : 7
  6.  
     
  7.  
    Destination/Mask Proto Pre Cost Flags NextHop Interface
  8.  
     
  9.  
    127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
  10.  
    127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  11.  
    127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  12.  
    192.168.1.0/24 Direct 0 0 D 192.168.1.3 GigabitEthernet0/0/0
  13.  
    192.168.1.3/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
  14.  
    192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
  15.  
    255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  16.  
     
  17.  
    <AR3>
学新通

        思科中用show

        华为默认的路由表如下:

  1.  
    <AR3>display ip routing-table
  2.  
    Route Flags: R - relay, D - download to fib
  3.  
    ------------------------------------------------------------------------------
  4.  
    Routing Tables: Public
  5.  
    Destinations : 4 Routes : 4
  6.  
     
  7.  
    Destination/Mask Proto Pre Cost Flags NextHop Interface
  8.  
     
  9.  
    127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
  10.  
    127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  11.  
    127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  12.  
    255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0

       Destination/Mask:目标/掩码。

        Proto:协议。

        Pre:优先级。

                直连路由默认优先级为0。

                OSPF华为默认优先级为10和150,思科默认优先级为110。

                静态路由华为默认为60,思科默认静态路由为10。

                RIP默认优先级为100。

                BGP默认优先级为255。

        Cost:开销。

        Flags:标识。下载到FIB。Route Flags:R-relay 中继。D-download to fib。

        NextHop:下一跳。想要发送数据的下一站。

        Interface:出接口。数据包发送的接口。一般出接口和下一跳在同一网段。

        为什么华为中有默认4个路由表?

4. 直连路由与非直连路由

        直连路由:配置IP地址,端口UP状态,形成直连路由。例如AR1与AR3,AR3与AR1、AR4,AR4与AR3、AR5,AR5与AR4。即:当接口配置IP地址,且IP地址和协议都是UP时,满足直连路由产生条件。

                优点:是所有路由当中优先级最高的。

                           是可以自动生成的。

                缺点:不能去往非直连的其它网段。

        非直连路由:需要静态路由或动态路由,将网段添加到路由表中。例如AR1与AR4。

学新通

         直连路由优先级高于非直连路由。

        为什么需要非直连路由?

                由于直连路由存在不足,不能去往非自己直连的其它网段。

                需要静态路由或动态路由,将网段添加到路由表中。

5. 路由转发规则

        被转发的路由必须存在。如果不存在,直接丢弃。

        1. 根据最长匹配原则进行,掩码越长,越优先转发。

        2. 当掩码一样,优先级的数值越小,越优先转发。

        3. 当掩码、优先级一样,开销越小,越优先转发。

        4. 当前述原则一致,负载分担。

6. 静态路由

        静态路由的应用场景

                1. 静态路由是指由管理员手动配置和维护的路由。

                2. 静态路由配置简单。无需像动态路由那样占用路由器的CPU资源来计算和分析路由更新。

                3. 静态路由一般适用于结构简单的网络。不过,即使是在复杂网络环境中,合理地配置一些静态路由也可以改进网络的性能。

        静态路由的3种语法

                在系统视图下执行:

                1. ip route-static  目标网段 目标网段掩码 出接口        #出接口即g0/0/0。

                2. ip route-static  目标网段 目标网段掩码 下一跳

                3. ip route-static  目标网段 目标网段掩码 出接口 下一跳        #推荐使用方式

         为什么不用出接口?容易产生解析失败。

        静态路由的不足:

                静态路由:不能动态的根据现网拓扑的改变而改变。

7. 下图为例:在AR10上如何访问路由3.3.3.3?

学新通

      先配置AR10,配完后暂时无法ping通3.3.3.3:

  1.  
    [Huawei]sysname AR10
  2.  
    [AR10]interface LoopBack 0
  3.  
    [AR10-LoopBack0]ip add 1.1.1.1 32
  4.  
    [AR10-LoopBack0]dis ip inter bri
  5.  
    *down: administratively down
  6.  
    ^down: standby
  7.  
    (l): loopback
  8.  
    (s): spoofing
  9.  
    The number of interface that is UP in Physical is 3
  10.  
    The number of interface that is DOWN in Physical is 2
  11.  
    The number of interface that is UP in Protocol is 2
  12.  
    The number of interface that is DOWN in Protocol is 3
  13.  
     
  14.  
    Interface IP Address/Mask Physical Protocol
  15.  
    GigabitEthernet0/0/0 unassigned up down
  16.  
    GigabitEthernet0/0/1 unassigned down down
  17.  
    GigabitEthernet0/0/2 unassigned down down
  18.  
    LoopBack0 1.1.1.1/32 up up(s)
  19.  
    NULL0 unassigned up up(s)
  20.  
    [AR10-LoopBack0]quit
  21.  
    [AR10]interface g0/0/0
  22.  
    [AR10-GigabitEthernet0/0/0]ip add 192.168.1.1 24
  23.  
    Aug 10 2023 18:27:50-08:00 AR10 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
  24.  
    [AR10-GigabitEthernet0/0/0]quit
  25.  
    [AR10]ping 3.3.3.3
  26.  
    PING 3.3.3.3: 56 data bytes, press CTRL_C to break
  27.  
    Request time out
  28.  
    Request time out
  29.  
    Request time out
  30.  
    Request time out
  31.  
    Request time out
  32.  
     
  33.  
    --- 3.3.3.3 ping statistics ---
  34.  
    5 packet(s) transmitted
  35.  
    0 packet(s) received
  36.  
    100.00% packet loss
  37.  
     
  38.  
    [AR10]
学新通

        配置AR11:

  1.  
    [AR11]inter g0/0/0
  2.  
    [AR11-GigabitEthernet0/0/0]ip add 192.168.1.2 24
  3.  
    [AR11-GigabitEthernet0/0/0]quit
  4.  
    [AR11]inte g0/0/1
  5.  
    [AR11-GigabitEthernet0/0/1]ip add 172.16.1.2 24
  6.  
    [AR11]inter LoopBack 0
  7.  
    [AR11-LoopBack0]ip add 2.2.2.2 32
  8.  
    [AR11-LoopBack0]quit
  9.  
    [AR11]dis ip inter brief
  10.  
    *down: administratively down
  11.  
    ^down: standby
  12.  
    (l): loopback
  13.  
    (s): spoofing
  14.  
    The number of interface that is UP in Physical is 4
  15.  
    The number of interface that is DOWN in Physical is 1
  16.  
    The number of interface that is UP in Protocol is 4
  17.  
    The number of interface that is DOWN in Protocol is 1
  18.  
     
  19.  
    Interface IP Address/Mask Physical Protocol
  20.  
    GigabitEthernet0/0/0 192.168.1.2/24 up up
  21.  
    GigabitEthernet0/0/1 172.16.1.2/24 up up
  22.  
    GigabitEthernet0/0/2 unassigned down down
  23.  
    LoopBack0 2.2.2.2/32 up up(s)
  24.  
    NULL0 unassigned up up(s)
  25.  
    <AR11>display ip routing-table
  26.  
    Route Flags: R - relay, D - download to fib
  27.  
    ------------------------------------------------------------------------------
  28.  
    Routing Tables: Public
  29.  
    Destinations : 11 Routes : 11
  30.  
     
  31.  
    Destination/Mask Proto Pre Cost Flags NextHop Interface
  32.  
     
  33.  
    2.2.2.2/32 Direct 0 0 D 127.0.0.1 LoopBack0
  34.  
    127.0.0.0/8 Direct 0 0 D 127.0.0.1 InLoopBack0
  35.  
    127.0.0.1/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  36.  
    127.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  37.  
    172.16.1.0/24 Direct 0 0 D 172.16.1.2 GigabitEthernet0/0/1
  38.  
    172.16.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
  39.  
    172.16.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/1
  40.  
    192.168.1.0/24 Direct 0 0 D 192.168.1.2 GigabitEthernet0/0/0
  41.  
    192.168.1.2/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
  42.  
    192.168.1.255/32 Direct 0 0 D 127.0.0.1 GigabitEthernet0/0/0
  43.  
    255.255.255.255/32 Direct 0 0 D 127.0.0.1 InLoopBack0
  44.  
     
  45.  
    <AR11>
学新通

        配置AR12:

  1.  
    [AR12]inter LoopBack 0
  2.  
    [AR12-LoopBack0]ip add 3.3.3.3 32
  3.  
    [AR12-LoopBack0]quit
  4.  
    [AR12]inter g0/0/0
  5.  
    [AR12-GigabitEthernet0/0/0]ip add 172.16.1.3 24
  6.  
    Aug 11 2023 15:34:54-08:00 AR12 %%01IFNET/4/LINK_STATE(l)[0]:The line protocol IP on the interface GigabitEthernet0/0/0 has entered the UP state.
  7.  
    [AR12-GigabitEthernet0/0/0]quit
  8.  
    [AR12]dis ip inter bri
  9.  
    *down: administratively down
  10.  
    ^down: standby
  11.  
    (l): loopback
  12.  
    (s): spoofing
  13.  
    The number of interface that is UP in Physical is 3
  14.  
    The number of interface that is DOWN in Physical is 2
  15.  
    The number of interface that is UP in Protocol is 3
  16.  
    The number of interface that is DOWN in Protocol is 2
  17.  
     
  18.  
    Interface IP Address/Mask Physical Protocol
  19.  
    GigabitEthernet0/0/0 172.16.1.3/24 up up
  20.  
    GigabitEthernet0/0/1 unassigned down down
  21.  
    GigabitEthernet0/0/2 unassigned down down
  22.  
    LoopBack0 3.3.3.3/32 up up(s)
  23.  
    NULL0 unassigned up up(s)
学新通

        配置完成后,AR10无法ping通3.3.3.3。

        因为数据在传递过程中,经过AR11,AR10会将数据传递给AR11,但AR11上没有通往3.3.3.3的路由。因此AR11设备会丢弃该报文。因此需要在AR11上写入静态路由,使之增加到达3.3.3.3的路由

[AR11]ip route-static 3.3.3.3 32 g0/0/0 192.168.1.1

        配置完成后,AR10依然无法ping通3.3.3.3。

        因为数据在传递过程中,AR0发现到达3.3.3.3需要通过AR11设备的172.16.1.2接口。因此AR10会将数据传递给AR11设备。AR11设备到达3.3.3.3需经过AR12设备的172.16.1.3接口。因此AR12会接收数据,并传给直连路由3.3.3.3。

        但是,如果想要ping通3.3.3.3,数据已然发送成功,也要接收成功。因此数据能够从AR12返回给AR10,才能ping通。

8. 负载分担与负载均衡

学新通

        负载分担:从AR6出来的流量 M N = 100%,但M != N,例如M = 40%,N = 60%。

        负载均衡:从AR6出来的流量 M N =  100%,且M = N = 50%。

        分逐流和逐包,默认逐流。

9. 路由器控制平面和转发平面

        路由器的两大典型功能:数据通道功能和控制功能。

        数据通道功能包括转发决定、背板转发以及输出链路调度等,一般由特定的硬件来完成;控制功能一般用软件完成,包括与相邻路由器之间的信息交接、系统配置、系统管理等。

        管理平面/控制平面(统称控制平面、分布平面)

                控制平面用于控制和管理所有网络协议的运行,例如生成树协议、VLAN协议、ARP协议、各种路由协议和组播协议等的管理与控制。

                控制平面通过网络协议提供给路由器/交换机对整个网络环境中的网络设备、连接链路和交互协议准确了解,并在网络状况发送改变时做出及时的调整以维护网络的正常运行。

                控制平面提供转发前所需的各种网络信息。

                控制平面并不占用过多的硬件资源,但在正常状态下依然是网络设备CPU资源的主要占用平面,控制平面主要靠CPU资源来处理信息。

                display ip routing-table 查看IP路由表,属控制平面范畴(路由信息数据库,RIB)。

                路由器不依赖控制平面进行数据转发。

        数据转发平面/数据平面

                对于数据处理过程中各种具体的处理转发过程,例如L2/L3/ACL/QOS/组播/安全防护等个功能的具体执行过程,都属于数据转发平面的任务范畴。

                display fib 查看最终迭代的出接口,属数据平面范畴(转发信息数据库,FIB)。

                路由器依赖数据平面进行数据转发。

10. 路由表和FIB表

        每个路由器都至少保存着一张路由表(routing-table)和一张FIB(Forwarding Information Base)表。

11. Loopback是逻辑接口,区别于实际的物理接口,只要配置IP地址,即为UP状态。配置命令为:

  1.  
    [AR11]inter LoopBack 0
  2.  
    [AR11-LoopBack0]ip add 2.2.2.2 32

12. 默认路由

        默认路由一般在末节点配置。优点是仅仅用一条路由代替所有路由条目。

[AR10]ip route-static 0.0.0.0  0 下一跳

        注意:0.0.0.0  0  表示任意IP,其中第5个0为掩码,表示32个0。

        明细路由:具体到某一网段。

        默认路由:

        路由转发规则:明细路由优先级高于默认路由。如果路由表当中明细路由和默认路由同时存在,则明细路由优先转发。当路由表中只有默认路由时,会选择默认路由。

        一般不要在中间节点写2条默认路由,容易产生环路。

13. 删除路由

[AR10]undo ip route-static 3.3.3.0 255.255.255.0 GigabitEthernet0/0/0 192.168.1.2

        先查看当前的静态路由,之后通过undo删除: 

  1.  
    [AR10]display current-configuration
  2.  
    [V200R003C00]
  3.  
    #
  4.  
    sysname AR10
  5.  
    #
  6.  
    snmp-agent local-engineid 800007DB03000000000000
  7.  
    snmp-agent
  8.  
    #
  9.  
    clock timezone China-Standard-Time minus 08:00:00
  10.  
    #
  11.  
    portal local-server load flash:/portalpage.zip
  12.  
    #
  13.  
    drop illegal-mac alarm
  14.  
    #
  15.  
    wlan ac-global carrier id other ac id 0
  16.  
    #
  17.  
    set cpu-usage threshold 80 restore 75
  18.  
    #
  19.  
    aaa
  20.  
    authentication-scheme default
  21.  
    authorization-scheme default
  22.  
    accounting-scheme default
  23.  
    domain default
  24.  
    domain default_admin
  25.  
    local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
  26.  
    local-user admin service-type http
  27.  
    #
  28.  
    firewall zone Local
  29.  
    priority 15
  30.  
    #
  31.  
    interface GigabitEthernet0/0/0
  32.  
    ip address 192.168.1.1 255.255.255.0
  33.  
    #
  34.  
    interface GigabitEthernet0/0/1
  35.  
    #
  36.  
    interface GigabitEthernet0/0/2
  37.  
    #
  38.  
    interface NULL0
  39.  
    #
  40.  
    interface LoopBack0
  41.  
    ip address 1.1.1.1 255.255.255.255
  42.  
    #
  43.  
    ip route-static 3.3.3.0 255.255.255.0 GigabitEthernet0/0/0 192.168.1.2
  44.  
    #
  45.  
    user-interface con 0
  46.  
    authentication-mode password
  47.  
    user-interface vty 0 4
  48.  
    user-interface vty 16 20
  49.  
    #
  50.  
    wlan ac
  51.  
    #
  52.  
    return
  53.  
    [AR10]undo ip route-static 3.3.3.0 255.255.255.0 GigabitEthernet0/0/0 192.168.1.2
  54.  
    [AR10]display current-configuration
  55.  
    [V200R003C00]
  56.  
    #
  57.  
    sysname AR10
  58.  
    #
  59.  
    snmp-agent local-engineid 800007DB03000000000000
  60.  
    snmp-agent
  61.  
    #
  62.  
    clock timezone China-Standard-Time minus 08:00:00
  63.  
    #
  64.  
    portal local-server load flash:/portalpage.zip
  65.  
    #
  66.  
    drop illegal-mac alarm
  67.  
    #
  68.  
    wlan ac-global carrier id other ac id 0
  69.  
    #
  70.  
    set cpu-usage threshold 80 restore 75
  71.  
    #
  72.  
    aaa
  73.  
    authentication-scheme default
  74.  
    authorization-scheme default
  75.  
    accounting-scheme default
  76.  
    domain default
  77.  
    domain default_admin
  78.  
    local-user admin password cipher %$%$K8m.Nt84DZ}e#<0`8bmE3Uw}%$%$
  79.  
    local-user admin service-type http
  80.  
    #
  81.  
    firewall zone Local
  82.  
    priority 15
  83.  
    #
  84.  
    interface GigabitEthernet0/0/0
  85.  
    ip address 192.168.1.1 255.255.255.0
  86.  
    #
  87.  
    interface GigabitEthernet0/0/1
  88.  
    #
  89.  
    interface GigabitEthernet0/0/2
  90.  
    #
  91.  
    interface NULL0
  92.  
    #
  93.  
    interface LoopBack0
  94.  
    ip address 1.1.1.1 255.255.255.255
  95.  
    #
  96.  
    user-interface con 0
  97.  
    authentication-mode password
  98.  
    user-interface vty 0 4
  99.  
    user-interface vty 16 20
  100.  
    #
  101.  
    wlan ac
  102.  
    #
  103.  
    return
  104.  
    [AR10]
学新通

14. 浮动路由

        浮动路由就是只让主链路进行工作,备链路不让转发流量。

        当主链路出现问题时,路由器选择备用链路。当主链路恢复,路由器会选择主链路。

15. 路由器转发数据使用 Routing table,而交换机转发数据使用cam cable。

这篇好文章是转载于:学新通技术网

  • 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
  • 本站站名: 学新通技术网
  • 本文地址: /boutique/detail/tanhhajcjh
系列文章
更多 icon
同类精品
更多 icon
继续加载