华为路由交换设备配置静态路由——双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]
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值