静态路由的配置

在这里插入图片描述

一、静态路由的配置

1、基本配置

配置路由器AR1
<Huawei>system
[Huawei]sysname R1
[R1]interface s0/0/0
[R1-Serial0/0/0]ip address 12.1.1.1 24
[R1-Serial0/0/0]q
[R1]interface s0/0/1
[R1-Serial0/0/1]ip address 13.1.1.1 24
[R1-Serial0/0/1]q
[R1]

配置路由器AR2
<Huawei>system
[Huawei]sysname R2
[R2]interface s0/0/0
[R2-Serial0/0/0]ip address 12.1.1.2 24
[R2]interface e0/0/0
[R2-Ethernet0/0/0]ip address 22.1.1.2 24


配置路由器AR3
<Huawei>system
[Huawei]sysname R3
[R3]interface s0/0/1
[R3-Serial0/0/1]ip address 13.1.1.3 24
[R3]interface e0/0/0
[R3-Ethernet0/0/0]ip address 33.1.1.3 24

2、配置静态路由
在每台路由器上配置静态路由协议,实现总部与两分部、两分部间的通信。
正向路由:在AR2上配置目的网段为主机PC2所在的网段的静态路由。
正向接力路由:在AR1上配置目的网段为主机PC2所在的网段的静态路由。
回程路由:在AR3上配置目的网段为主机PC1所在网段的静态路由。
回程接力路由:在AR1上配置目的网段为主机PC1所在的网段的静态路由。

正向路由
[R2]ip route-static 33.1.1.0 24 s0/0/0
正向接力路由
[R1]ip route-static 33.1.1.0 24 s0/0/1
回程路由
[R3]ip route-static 22.1.1.0 255.255.255.0 13.1.1.1
回程接力路由
[R1]ip route-static 22.1.1.0 24 s0/0/0

配置完成后,查看AR1的路由表。

<R1>display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 10       Routes : 10       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.1.1.0/24  Direct  0    0           D   12.1.1.1        Serial0/0/0
       12.1.1.1/32  Direct  0    0           D   127.0.0.1       Serial0/0/0
       12.1.1.2/32  Direct  0    0           D   12.1.1.2        Serial0/0/0
       13.1.1.0/24  Direct  0    0           D   13.1.1.1        Serial0/0/1
       13.1.1.1/32  Direct  0    0           D   127.0.0.1       Serial0/0/1
       13.1.1.3/32  Direct  0    0           D   13.1.1.3        Serial0/0/1
       22.1.1.0/24  Static  60   0           D   12.1.1.1        Serial0/0/0
       33.1.1.0/24  Static  60   0           D   13.1.1.1        Serial0/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
<R1>

3、验证配置效果
验证两分部的连通性,在PC1上测试与PC2间的连通性。

PC>ping 33.1.1.33

Ping 33.1.1.33: 32 data bytes, Press Ctrl_C to break
From 33.1.1.33: bytes=32 seq=1 ttl=125 time=187 ms
From 33.1.1.33: bytes=32 seq=2 ttl=125 time=109 ms
From 33.1.1.33: bytes=32 seq=3 ttl=125 time=125 ms
From 33.1.1.33: bytes=32 seq=4 ttl=125 time=109 ms
From 33.1.1.33: bytes=32 seq=5 ttl=125 time=109 ms

--- 33.1.1.33 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 109/127/187 ms

两分部之间通信正常,在主机PC1上使用tracert命令测试所经过的网关。
PC>tracert 33.1.1.33

traceroute to 33.1.1.33, 8 hops max
(ICMP), press Ctrl+C to stop
 1  22.1.1.2   16 ms  31 ms  31 ms
 2  12.1.1.1   63 ms  62 ms  47 ms
 3  13.1.1.3   94 ms  94 ms  94 ms
 4  33.1.1.33   109 ms  125 ms  125 ms
通过观察发现,PC1 ping的数据包是经过R1、R2、R3的顺序到达主机PC2的

验证总部与两分部之间的通信,在R1上使用ping命令测试。

//验证总部与分部PC1所在的网段
<R1>ping 22.1.1.22
  PING 22.1.1.22: 56  data bytes, press CTRL_C to break
    Reply from 22.1.1.22: bytes=56 Sequence=1 ttl=127 time=70 ms
    Reply from 22.1.1.22: bytes=56 Sequence=2 ttl=127 time=80 ms
    Reply from 22.1.1.22: bytes=56 Sequence=3 ttl=127 time=30 ms
    Reply from 22.1.1.22: bytes=56 Sequence=4 ttl=127 time=60 ms
    Reply from 22.1.1.22: bytes=56 Sequence=5 ttl=127 time=50 ms

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

//验证总部与分部PC2所在的网段
<R1>ping 33.1.1.33
  PING 33.1.1.33: 56  data bytes, press CTRL_C to break
    Reply from 33.1.1.33: bytes=56 Sequence=1 ttl=127 time=80 ms
    Reply from 33.1.1.33: bytes=56 Sequence=2 ttl=127 time=100 ms
    Reply from 33.1.1.33: bytes=56 Sequence=3 ttl=127 time=90 ms
    Reply from 33.1.1.33: bytes=56 Sequence=4 ttl=127 time=110 ms
    Reply from 33.1.1.33: bytes=56 Sequence=5 ttl=127 time=60 ms

  --- 33.1.1.33 ping statistics ---
    5 packet(s) transmitted
    5 packet(s) received
    0.00% packet loss
    round-trip min/avg/max = 60/88/110 ms

通过测试,总部路由器R1能够正常访问两个分部主机PC1和PC2的网络

二、浮动静态路由的配置

在之前的案例配置上继续进行实验。
1、基本配置
在R2和R3增加主用链路接口基本设置

[r2]interface s0/0/0
[r2-Serial0/0/0]ip address 12.1.1.2 24

[r3]interface s0/0/2	
[r3-Serial0/0/2]ip address 22.1.1.3 24

2、配置静态路由
在R2和R3增加主用链路静态路由的配置。

[r2]ip route-static 33.1.1.0 24 23.1.1.3

[r3]ip route-static 22.1.1.0 24 23.1.1.2

查看R2的路由表。

<r2>display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 11       Routes : 12       

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       12.1.1.0/24  Direct  0    0           D   12.1.1.2        Serial0/0/0
       12.1.1.1/32  Direct  0    0           D   12.1.1.1        Serial0/0/0
       12.1.1.2/32  Direct  0    0           D   127.0.0.1       Serial0/0/0
       22.1.1.0/24  Direct  0    0           D   22.1.1.2        GigabitEthernet
0/0/0
       22.1.1.2/32  Direct  0    0           D   127.0.0.1       GigabitEthernet
0/0/0
       22.1.1.3/32  Direct  0    0           D   22.1.1.3        Serial0/0/2
       23.1.1.0/24  Direct  0    0           D   23.1.1.2        Serial0/0/2
       23.1.1.2/32  Direct  0    0           D   127.0.0.1       Serial0/0/2
       33.1.1.0/24  Static  60   0           D   12.1.1.2        Serial0/0/0
                    Static  60   0          RD   23.1.1.3        Serial0/0/2
      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

<r2>display ip routing-table protocol static 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
         Destinations : 1        Routes : 2        Configured Routes : 2

Static routing table status : <Active>
         Destinations : 1        Routes : 2

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       33.1.1.0/24  Static  60   0           D   12.1.1.2        Serial0/0/0
                    Static  60   0          RD   23.1.1.3        Serial0/0/2

Static routing table status : <Inactive>
         Destinations : 0        Routes : 0

3、配置浮动静态路由
修改R2去往PC2所在网段经过R1静态路由的优先级。关键词PREFERENCE取值越小,优先级越高;取值越大,优先级越小。

[r2]ip route-static 33.1.1.0 24 s0/0/0 preference 80

修改R3去往PC1所在网段经过R1静态路由的优先级。

[r3]ip route-static 22.1.1.0 24 13.1.1.1 preference 80

在R2使用命令查看路由表中静态路由条目。

<r2>display ip routing-table protocol static 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Public routing table : Static
         Destinations : 1        Routes : 2        Configured Routes : 2

Static routing table status : <Active>
         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       33.1.1.0/24  Static  60   0          RD   23.1.1.3        Serial0/0/2

Static routing table status : <Inactive>
         Destinations : 1        Routes : 1

Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface

       33.1.1.0/24  Static  80   0               12.1.1.2        Serial0/0/0

4、验证配置效果

PC>ping 33.1.1.33

Ping 33.1.1.33: 32 data bytes, Press Ctrl_C to break
From 33.1.1.33: bytes=32 seq=1 ttl=126 time=94 ms
From 33.1.1.33: bytes=32 seq=2 ttl=126 time=110 ms
From 33.1.1.33: bytes=32 seq=3 ttl=126 time=94 ms
From 33.1.1.33: bytes=32 seq=4 ttl=126 time=109 ms
From 33.1.1.33: bytes=32 seq=5 ttl=126 time=47 ms

--- 33.1.1.33 ping statistics ---
  5 packet(s) transmitted
  5 packet(s) received
  0.00% packet loss
  round-trip min/avg/max = 47/90/110 ms

PC>tracert 33.1.1.33

traceroute to 33.1.1.33, 8 hops max
(ICMP), press Ctrl+C to stop
 1  22.1.1.2   15 ms  32 ms  47 ms
 2  22.1.1.3   46 ms  63 ms  62 ms
 3  33.1.1.33   94 ms  125 ms  110 ms

由观察可知,两分部之间可以正常通信,且PC1 ping的数据包是经过R1、R3的顺序到达主机PC2的。

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值