华为路由交换设备配置静态路由——双DEMO

Demo1

实验拓扑如下:

配置两台PC机


配置两台路由器

R1

<Huawei>
<Huawei>system-view                            //进入用户视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R1                            //修改路由名称为R1
[R1]
[R1]int g 0/0/0                               //进入g0/0/0接口
[R1-GigabitEthernet0/0/0]ip add 192.168.10.1 24         //配置IP
[R1-GigabitEthernet0/0/0]undo shut                    //开启
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R1-GigabitEthernet0/0/0]q                     //返回普通视图
[R1]int g 0/0/1
[R1-GigabitEthernet0/0/1]ip add 12.0.0.1 30
[R1-GigabitEthernet0/0/1]un sh
[R1-GigabitEthernet0/0/1]q
[R1]

R2

<Huawei>
<Huawei>sys
[Huawei]sys R2
[R2]
[R2]int g 0/0/0
[R2-GigabitEthernet0/0/0]ip add 12.0.0.2 30
[R2-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R2-GigabitEthernet0/0/0]q
[R2]int LoopBack 0                                    //进入回环网卡lo0中(且回环网卡不需要undo shut)
[R2-LoopBack0]ip add 2.2.2.2
[R2-LoopBack0]q
[R2]

此时,虽然两台路由均在接口上配置了IP地址,但由于存在多网段,所以仍需要配置静态/默认路由。

R1配置默认路由

[R1]
[R1]ip route-static 0.0.0.0 0.0.0.0 12.0.0.2       //允许所有网段通过
[R1]int g 0/0/1
[R1-GigabitEthernet0/0/1]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 7        Routes : 7        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        0.0.0.0/0   Static  60   0          RD   12.0.0.2        GigabitEthernet
0/0/1
       12.0.0.0/30  Direct  0    0           D   12.0.0.1        GigabitEthernet
0/0/1
       12.0.0.1/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
   192.168.10.0/24  Direct  0    0           D   192.168.10.1    GigabitEthernet
0/0/0
   192.168.10.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0

[R1-GigabitEthernet0/0/1]q
[R1]

R2配置静态路由

[R2]
[R2]ip route-static 192.168.10.0 24 12.0.0.1       //学习10.0网段
[R2]int g0/0/0
[R2-GigabitEthernet0/0/0]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 6        Routes : 6        

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        2.2.2.2/32  Direct  0    0           D   127.0.0.1       LoopBack0
       12.0.0.0/30  Direct  0    0           D   12.0.0.2        GigabitEthernet
0/0/0
       12.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
      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
   192.168.10.0/24  Static  60   0          RD   12.0.0.1        GigabitEthernet
0/0/0

[R2-GigabitEthernet0/0/0]q
[R2]

实验结果验证

PC>ping 192.168.10.20              //联通另一台PC机

Ping 192.168.10.20: 32 data bytes, Press Ctrl_C to break
From 192.168.10.20: bytes=32 seq=1 ttl=128 time=47 ms
From 192.168.10.20: bytes=32 seq=2 ttl=128 time=31 ms

--- 192.168.10.20 ping statistics ---
  2 packet(s) transmitted
  2 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 31/39/47 ms

PC>ping 2.2.2.2                       //尝试联通不同网段的Lo0回环网卡

Ping 2.2.2.2: 32 data bytes, Press Ctrl_C to break
From 2.2.2.2: bytes=32 seq=1 ttl=254 time=78 ms
From 2.2.2.2: bytes=32 seq=2 ttl=254 time=78 ms
From 2.2.2.2: bytes=32 seq=3 ttl=254 time=594 ms
From 2.2.2.2: bytes=32 seq=4 ttl=254 time=78 ms
From 2.2.2.2: bytes=32 seq=5 ttl=254 time=62 ms

--- 2.2.2.2 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 62/178/594 ms

PC>

Demo2

实验拓扑如下

给三台交换机各接口配置IP,及Lo0网卡的配置

R3

<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R3
[R3]int g0/0/0
[R3-GigabitEthernet0/0/0]ip add 12.0.0.1 24
[R3-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R3-GigabitEthernet0/0/0]q
[R3]int g0/0/1
[R3-GigabitEthernet0/0/1]ip add 13.0.0.1 24
[R3-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R3-GigabitEthernet0/0/1]q
[R3]
[R3]int loo 0
[R3-LoopBack0]ip add 1.1.1.1 32
[R3-LoopBack0]q
[R3]

R4

<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sys
[Huawei]sysname R4
[R4]int g0/0/0
[R4-GigabitEthernet0/0/0]ip add 12.0.0.2 24
[R4-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R4-GigabitEthernet0/0/0]q
[R4]int g 0/0/1
[R4-GigabitEthernet0/0/1]ip add 23.0.0.2 24
[R4-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R4-GigabitEthernet0/0/1]q
[R4]int LoopBack 0
[R4-LoopBack0]ip add 2.2.2.2 32
[R4-LoopBack0]q
[R4]

R5

<Huawei>sy
Enter system view, return user view with Ctrl+Z.
[Huawei]sys R5
[R5]int g 0/0/0
[R5-GigabitEthernet0/0/0]ip add 13.0.0.3 24
[R5-GigabitEthernet0/0/0]un sh
Info: Interface GigabitEthernet0/0/0 is not shutdown.
[R5-GigabitEthernet0/0/0]q
[R5]int g 0/0/1
[R5-GigabitEthernet0/0/1]ip add 23.0.0.3 24
[R5-GigabitEthernet0/0/1]un sh
Info: Interface GigabitEthernet0/0/1 is not shutdown.
[R5-GigabitEthernet0/0/1]q
[R5]int loo 0
[R5-LoopBack0]ip add 3.3.3.3 32
[R5-LoopBack0]q
[R5]

为三台交换机配置静态路由

R3

[R3]
[R3]ip route-static 3.3.3.3 32 13.0.0.3
[R3]ip route-static 3.3.3.3 32 12.0.0.2
[R3]ip route-static 2.2.2.2 32 13.0.0.3
[R3]ip route-static 2.2.2.2 32 12.0.0.2
[R3]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 9        Routes : 11       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.1.1.1/32  Direct  0    0           D   127.0.0.1       LoopBack0
        2.2.2.2/32  Static  60   0          RD   13.0.0.3        GigabitEthernet
0/0/1
                    Static  60   0          RD   12.0.0.2        GigabitEthernet
0/0/0
        3.3.3.3/32  Static  60   0          RD   13.0.0.3        GigabitEthernet
0/0/1
                    Static  60   0          RD   12.0.0.2        GigabitEthernet
0/0/0
       12.0.0.0/24  Direct  0    0           D   12.0.0.1        GigabitEthernet
0/0/0
       12.0.0.1/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       13.0.0.0/24  Direct  0    0           D   13.0.0.1        GigabitEthernet
0/0/1
       13.0.0.1/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

[R3]

R4

[R4]
[R4]ip route-static 1.1.1.1 32 12.0.0.1
[R4]ip route-static 1.1.1.1 32 23.0.0.3
[R4]ip route-static 3.3.3.3 32 12.0.0.1
[R4]ip route-static 3.3.3.3 32 23.0.0.3
[R4]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 9        Routes : 11       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.1.1.1/32  Static  60   0          RD   12.0.0.1        GigabitEthernet
0/0/0
                    Static  60   0          RD   23.0.0.3        GigabitEthernet
0/0/1
        2.2.2.2/32  Direct  0    0           D   127.0.0.1       LoopBack0
        3.3.3.3/32  Static  60   0          RD   12.0.0.1        GigabitEthernet
0/0/0
                    Static  60   0          RD   23.0.0.3        GigabitEthernet
0/0/1
       12.0.0.0/24  Direct  0    0           D   12.0.0.2        GigabitEthernet
0/0/0
       12.0.0.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       23.0.0.0/24  Direct  0    0           D   23.0.0.2        GigabitEthernet
0/0/1
       23.0.0.2/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

[R4]

R5

[R5]
[R5]ip route-static 1.1.1.1 32 13.0.0.1
[R5]ip route-static 1.1.1.1 32 23.0.0.2
[R5]ip route-static 2.2.2.2 32 13.0.0.1
[R5]ip route-static 2.2.2.2 32 23.0.0.2
[R5]dis ip routing
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 9        Routes : 11       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

        1.1.1.1/32  Static  60   0          RD   13.0.0.1        GigabitEthernet
0/0/0
                    Static  60   0          RD   23.0.0.2        GigabitEthernet
0/0/1
        2.2.2.2/32  Static  60   0          RD   13.0.0.1        GigabitEthernet
0/0/0
                    Static  60   0          RD   23.0.0.2        GigabitEthernet
0/0/1
        3.3.3.3/32  Direct  0    0           D   127.0.0.1       LoopBack0
       13.0.0.0/24  Direct  0    0           D   13.0.0.3        GigabitEthernet
0/0/0
       13.0.0.3/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       23.0.0.0/24  Direct  0    0           D   23.0.0.3        GigabitEthernet
0/0/1
       23.0.0.3/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

[R5]

实验结果验证

#R3
[R3]ping 3.3.3.3
  PING 3.3.3.3: 56  data bytes, press CTRL_C to break
    Reply from 3.3.3.3: bytes=56 Sequence=1 ttl=255 time=50 ms
    Reply from 3.3.3.3: bytes=56 Sequence=2 ttl=255 time=40 ms
    Reply from 3.3.3.3: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 3.3.3.3: bytes=56 Sequence=4 ttl=255 time=10 ms
    Reply from 3.3.3.3: bytes=56 Sequence=5 ttl=255 time=40 ms

  --- 3.3.3.3 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 10/32/50 ms

[R3]

#R4
[R4]ping 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=255 time=80 ms
    Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=255 time=50 ms
    Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=255 time=50 ms
    Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=255 time=30 ms
    Reply from 1.1.1.1: bytes=56 Sequence=5 ttl=255 time=50 ms

  --- 1.1.1.1 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 30/52/80 ms

[R4]

#R5
[R5]ping 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=255 time=50 ms
    Reply from 1.1.1.1: bytes=56 Sequence=2 ttl=255 time=50 ms
    Reply from 1.1.1.1: bytes=56 Sequence=3 ttl=255 time=50 ms
    Reply from 1.1.1.1: bytes=56 Sequence=4 ttl=255 time=50 ms

  --- 1.1.1.1 ping statistics ---
    4 packet(s) transmitted
    4 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 50/50/50 ms

[R5]

原文地址:https://blog.51cto.com/14484404/2444900

时间: 2024-10-07 23:03:40

华为路由交换设备配置静态路由——双DEMO的相关文章

路由交换(六):路由基础及静态路由

路由基础及静态路由 一.路由基础 1.路由器工作原理 路由器收到一个数据报文,先检查目的IP地址,再查找路由表.查找到匹配的路由表项后根据该表项的出接口和下一跳将数据报转发.路由表项一般分为直连路由.静态路由.动态路由.IP路由表中存放最优路由条目.最优路由标目一般根据最长匹配原则.路由优先级.路由度量值来选择. 最长匹配原则:路由表中如果存在多个匹配目的网络的路由条目,选择掩码长度最长的条目加表 路由优先级:当掩码长度相同,比较路由优先级,路由协议优先级越小越优先 路由度量值:当路由优先级相同

路由技术之 静态路由与默认路由

路由技术之 静态路由与默认路由 1.简单理解 静态路由:手动添加一条路由信息,格式如: R1(config)#ip route 1.1.1.0 [想要联通的网段] 255.255.255.0 [网段的子网掩码] 2.2.2.2 [本路由器的出接口或与本路由器出接口连接的那个路由器接口的ip,也就是专业术语:'吓一条'] 默认路由:就是告诉路由器,当你不知道怎么和其它网络连接时,都找我这条路就OK 了 R1(config)#ip route 0.0.0.0   0.0.0.0   2.2.2.2 

HCNA——IP路由原理、静态路由基本配置

HCNA--IP路由原理.静态路由基本配置 在互联网中进行路由选择所使用的设备,或者说,实现路由的设备,我们称之为路由器. 路由器关键功能 检查数据包的目的地 确定信息源 发现可能的路由 选择最佳路由 验证和维护路由信息 什么是路由? 路由是指导IP报文发送的路径信息 路由表 路由器工作时依赖于路由表进行数据的转发.路由表犹如一张地图,它包含着去往各个目的的路径信息(路由条目).每条信息至少应该包括下面3个内容: 目的网络--表明路由器可以到达的网络的地址,可理解为去哪里. 下一跳--通常情况下

华为交换之间静态路由配置实例

拓扑图 左边交换机配置: <Huawei>dis cu # sysname Huawei # vlan batch 10 100 # cluster enable ntdp enable ndp enable # drop illegal-mac alarm # diffserv domain default # drop-profile default # aaa  authentication-scheme default  authorization-scheme default  ac

路由基础及静态路由

路由介绍: 什么是路由: 路由就是寻径,是指路由器在收到IP包后,去查找自已的路由信息进行转发的过程. 路由信息就是去往目的地的一条信息,它指明了去往目的地的方向,通常也把路由信息简称为路由. 要完成对数据包的传输,路由器必须知道并处理哪些信息: 目的地址 相邻路由器,并且能够从邻居处获得远程网络的信息 到远程网络的所有可能的路径 能计算出到达远程网络的最佳路径 要能够维护并验证路由信息,在路径发生改变时,要能很快的知道 什么是路由表: 路由器使用一个路由表来保存去往目的地的路由信息,路由表中的

Centos网络管理(四)-路由转发与静态路由

实验环境:VMware Workstation Pro 14(试用版) 系统平台: CentOS release 6.9 (Final)       内核  2.6.32-696.el6.x86_64 CentOS Linux release 7.4.1708 (Core)  内核  3.10.0-693.el7.x86_64 机器 简称 角色 IP地址 6-2-A A 模拟电脑A eth1 192.168.27.210/24 7-2-R1 R1 路由器R1 ens33 192.168.27.2

CCNA 路由 第九节 静态路由

创作:http://www.ie-lab.cn/ 原文地址:https://blog.51cto.com/14248289/2380142

华为eNSP路由交换-静态路由

静态路由 一. 静态路由及默认路由基本配置 1.1实验内容 在由三台路由器所组成的简单网络中,R1和R3各连着一台PC,现在要求能够实现PC-1和PC-2之间的通信.本实验将通过配置基本的静态路由和默认路由来实现. 1.2实验拓扑图 1.3实验编址 1.4实验步骤 1.4.1基本配置 (1).根据实验编址表进行相应的基本配置,并使用ping命令来测试直连网段的连通性. [R1-Ethernet0/0/0]ip address 192.168.10.1 24 [R1-Serial0/0/0]ip

华为静态路由配置

======================================================== IP路由基础 查看路由表 display ip routing-table interface 输出接口 nexthop   下一跳IP地址 proto     路由协议 pre       优先级 cost      开销.度量 ======================================================== 静态路由配置 配置静态路由 ip rou