码迷,mamicode.com
首页 > 其他好文 > 详细

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

时间:2019-10-23 22:20:23      阅读:83      评论:0      收藏:0      [点我收藏+]

标签:ret   src   mask   交换   设备   byte   flags   dir   down   

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]

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

标签:ret   src   mask   交换   设备   byte   flags   dir   down   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!