步骤一 基础配置和IP编址

在R1、R2上配置设备名称和IP地址。

配置R1

<Huawei>system-view 
[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/0
[R1-GigabitEthernet0/0/0]ip address 10.1.1.254 255.255.255.0
[R1-GigabitEthernet0/0/0]quit
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.1.12.1 24 255.255.255.0
[R1-GigabitEthernet0/0/1]quit
[R1]interface GigabitEthernet 0/0/2
[R1-GigabitEthernet0/0/2]ip address 10.1.22.1 24 255.255.255.0
[R1-GigabitEthernet0/0/2]quit

配置R2

<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]sysname R2
[R2]interface GigabitEthernet 0/0/0
[R2-GigabitEthernet0/0/0]ip address 172.16.1.254 24 
[R2-GigabitEthernet0/0/0]quit 
[R2]interface GigabitEthernet0/0/1
[R2-GigabitEthernet0/0/1]ip add 10.1.12.2 24 
[R2-GigabitEthernet0/0/1]quit
[R2]interface GigabitEthernet0/0/2
[R2-GigabitEthernet0/0/2]ip add 10.1.22.2 24 
[R2-GigabitEthernet0/0/2]quit

执行display current-configuration命令,检查配置情况。

执行display ip interface brief命令,检查配置情况。

[R1]display ip interface brief
Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              10.1.1.254/24        up         up        
GigabitEthernet0/0/1              10.1.12.1/24         up         up        
GigabitEthernet0/0/2              10.1.22.1/24         up         up        


<R2>display ip interface brief
Interface                         IP Address/Mask      Physical   Protocol  
GigabitEthernet0/0/0              172.16.1.254/24      up         up        
GigabitEthernet0/0/1              10.1.12.2/24         up         up        
GigabitEthernet0/0/2              10.1.22.2/24         up         up

配置好PC1、PC2的IP地址、子网掩码、网关。

执行ping命令,检测R1与直连网络的连通性。

<R1>ping 10.1.12.2
  PING 10.1.12.2: 56  data bytes, press CTRL_C to break
    Reply from 10.1.12.2: bytes=56 Sequence=1 ttl=255 time=120 ms
    Reply from 10.1.12.2: bytes=56 Sequence=2 ttl=255 time=30 ms
    Reply from 10.1.12.2: bytes=56 Sequence=3 ttl=255 time=20 ms
    Reply from 10.1.12.2: bytes=56 Sequence=4 ttl=255 time=20 ms
Reply from 10.1.12.2: bytes=56 Sequence=5 ttl=255 time=20 ms
<R1>ping 10.1.22.2
  PING 10.1.22.2: 56  data bytes, press CTRL_C to break
    Reply from 10.1.22.2: bytes=56 Sequence=1 ttl=255 time=130 ms
    Reply from 10.1.22.2: bytes=56 Sequence=2 ttl=255 time=20 ms
    Reply from 10.1.22.2: bytes=56 Sequence=3 ttl=255 time=30 ms
    Reply from 10.1.22.2: bytes=56 Sequence=4 ttl=255 time=20 ms
    Reply from 10.1.22.2: bytes=56 Sequence=5 ttl=255 time=60 ms
<R1>ping 10.1.1.1
  PING 10.1.1.1: 56  data bytes, press CTRL_C to break
    Reply from 10.1.1.1: bytes=56 Sequence=1 ttl=128 time=20 ms
    Reply from 10.1.1.1: bytes=56 Sequence=2 ttl=128 time=20 ms
    Reply from 10.1.1.1: bytes=56 Sequence=3 ttl=128 time=20 ms
    Reply from 10.1.1.1: bytes=56 Sequence=4 ttl=128 time=20 ms
    Reply from 10.1.1.1: bytes=56 Sequence=5 ttl=128 time=30 ms

执行ping命令,检测R2直连网络的连通性。

<R2>ping 172.16.1.2
  PING 172.16.1.2: 56  data bytes, press CTRL_C to break
    Reply from 172.16.1.2: bytes=56 Sequence=1 ttl=128 time=30 ms
    Reply from 172.16.1.2: bytes=56 Sequence=2 ttl=128 time=30 ms
    Reply from 172.16.1.2: bytes=56 Sequence=3 ttl=128 time=20 ms
    Reply from 172.16.1.2: bytes=56 Sequence=4 ttl=128 time=30 ms
    Reply from 172.16.1.2: bytes=56 Sequence=5 ttl=128 time=10 ms


      步骤二 测试PC1到目的网络172.16.1.0/24的连通性

PC1>ping 172.16.1.2
Ping 172.16.1.2: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!

PC1如果要与172.16.1.0/24网络通信,需要R1上有去往该网段的路由信息,并且R2上也需要有到R1相应接口G0/0/0所在IP网段的路由信息。

上述检测结果表明,PC1不能与172.16.1.2所在网络通信。 

执行display ip routing-table命令,查看R1上的路由表。可以发现路由表中没有到这个网段172.16.1.0/24的路由信息。

[R1]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 13       Routes : 13       
Destination/Mask      Proto   Pre  Cost      Flags   NextHop        Interface
     10.1.1.0/24      Direct    0    0           D   10.1.1.254       GigabitEthernet0/0/0
     10.1.1.254/32    Direct    0    0           D   127.0.0.1        GigabitEthernet0/0/0
     10.1.1.255/32    Direct    0    0           D   127.0.0.1        GigabitEthernet0/0/0
      10.1.12.0/24    Direct    0    0           D   10.1.12.1        GigabitEthernet0/0/1
      10.1.12.1/32    Direct    0    0           D   127.0.0.1        GigabitEthernet0/0/1
    10.1.12.255/32    Direct    0    0           D   127.0.0.1        GigabitEthernet0/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
127.255.255.255/32    Direct    0    0           D   127.0.0.1        InLoopBack0
255.255.255.255/32    Direct    0    0           D   127.0.0.1        InLoopBack0

      步骤三 在R1上配置静态路由

配置目的地址为172.16.1.0/24的静态路由,路由的下一跳配置为R2的G0/0/1接口IP地址10.1.12.2。默认静态路由优先级为60,无需额外配置路由优先级信息。

[R1]ip route-static 172.16.1.0 24 10.1.12.2

 

     步骤四 在R2上配置静态路由

配置R2到10.1.1.0/24网段的路由

[R2]ip route-static 10.1.1.0 24 10.1.12.1

  
查看R1的路由表

[R1]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 13       Routes : 13       
Destination/Mask    Proto   Pre  Cost      Flags   NextHop         Interface
     172.16.1.0/24    Static  60   0          RD    10.1.12.2       GigabitEthernet0/0/1

查看R2的路由表

[R2]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 15       
Destination/Mask    Proto   Pre  Cost      Flags  NextHop         Interface
       10.1.1.0/24   Static    60    0        RD   10.1.12.1      GigabitEthernet0/0/1

检测PC1到目的地址PC2 172.16.1.2的连通性。

PC1>ping 172.16.1.2
Ping 172.16.1.2: 32 data bytes, Press Ctrl_C to break
From 172.16.1.2: bytes=32 seq=1 ttl=125 time=31 ms
From 172.16.1.2: bytes=32 seq=2 ttl=125 time=15 ms
From 172.16.1.2: bytes=32 seq=3 ttl=125 time=31 ms
From 172.16.1.2: bytes=32 seq=4 ttl=125 time=16 ms
From 172.16.1.2: bytes=32 seq=5 ttl=125 time=16 ms

以上回显表示通过在R1和R2上配置静态路由,PC1所在网络可以正常访问PC2所在的网络。

        步骤五 配置备份静态路由

R1与网络172.16.1.0/24之间交互的数据通过R1与R2间的主链路传输。如果R1和R2间的主链路发生故障,R1将不能与网络172.16.1.0/24通信。 

但是根据拓扑图可以看出,当R1和R2间的主链路发生故障时,R1还可以通过R1与R2间的备份链路与172.16.1.0/24通信。所以可以通过配置一条备份静态路由实现路由的冗余备份。正常情况下,备份静态路由不生效。当R1和R2间的主链路发生故障时,才使用备份静态路由传输数据。 

配置备份静态路由时,需要修改备份静态路由的优先级,确保只有主链路故障时才使用备份路由。本任务中,需要将备份静态路由的优先级修改为80。

配置R1到172.16.1.0/24的备份路由

[R1]ip route-static 172.16.1.0 24 10.1.22.2 preference 80

配置R2到10.1.1.0/24的备份路由

[R2]ip route-static 10.1.1.0 24 10.1.22.1 preference 80

 

       步骤六 验证静态路由

在R1和R2的路由表中,查看当前的静态路由配置。

[R1]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 13       Routes : 13       
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
     172.16.1.0/24  Static  60    0        RD   10.1.12.2       GigabitEthernet0/0/1

[R2]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 14       Routes : 15       
Destination/Mask    Proto   Pre  Cost      Flags NextHop         Interface
       10.1.1.0/24  Static  60    0        RD   10.1.12.1      GigabitEthernet0/0/1

路由表中Protocol字段的值是Static,表明该路由是静态路由。Preference字段的值是60,表明该路由使用的是默认优先级。

当R1和R2之间主链路正常时,PC1与网络172.16.1.0/24之间交互的数据通过主链路传输。在PC1上执行tracert命令,可以查看数据的传输路径。

PC1>tracert 172.16.1.2
traceroute to 172.16.1.2, 8 hops max
(ICMP), press Ctrl+C to stop
 1  10.1.1.254   <1 ms  15 ms  <1 ms
 2  10.1.12.2    32 ms  15 ms  16 ms
 3  172.16.1.2   31 ms  47 ms  15 ms

命令的回显信息证实R1将数据发送给R2,经过主链路进行传输。

 

      步骤七 验证备份静态路由

关闭R1上的G0/0/1接口,模拟R1与R2间的主链路发生故障,然后查看IP路由表的变化。

[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]shutdown
[R1-GigabitEthernet0/0/1]quit

注意与关闭接口之前的路由表情况作对比。
 

[R1]disp ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 11       Routes : 11       
Destination/Mask    Proto   Pre  Cost      Flags  NextHop         Interface
   172.16.1.0/24    Static   80   0         RD   10.1.22.2       GigabitEthernet0/0/2

在R1的路由表中,灰色所标记出的路由的下一跳和优先级均已发生变化。

检测PC1到目的地址172.16.1.2的连通性。

PC1>ping 172.16.1.2
Ping 172.16.1.2: 32 data bytes, Press Ctrl_C to break
From 172.16.1.2: bytes=32 seq=1 ttl=125 time=31 ms
From 172.16.1.2: bytes=32 seq=2 ttl=125 time=15 ms
From 172.16.1.2: bytes=32 seq=3 ttl=125 time=31 ms
From 172.16.1.2: bytes=32 seq=4 ttl=125 time=16 ms
From 172.16.1.2: bytes=32 seq=5 ttl=125 time=16 ms

网络并未因为R1与R2之间的主链路被关闭而中断。

在PC1上执行tracert命令,查看数据包的转发路径。

PC>tracert 172.16.1.2
traceroute to 172.16.1.2, 8 hops max
(ICMP), press Ctrl+C to stop
 1  10.1.1.254   16 ms  15 ms  <1 ms
 2  10.1.22.2    31 ms  16 ms  31 ms
 3  172.16.1.2   47 ms  46 ms  32 ms

命令的回显信息表明,R1转发目的地为172.16.1.2的数据经过备份链路抵达。
 

      步骤八 配置缺省路由实现网络的互通

打开R1上在步骤七中关闭的接口。

[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]undo shutdown

打开R2上创建Loopback0接口配置IP地址192.168.0.254/24,模拟另一个网络的网段。

R2]interface LoopBack 0
[R2-LoopBack0]ip address 192.168.0.254 255.255.255.0
[R2-LoopBack0]quit
[R2]

验证从PC1到192.168.0.254/24网络的连通性。

PC1>ping 192.168.0.254
Ping 192.168.0.254: 32 data bytes, Press Ctrl_C to break
Request timeout!
Request timeout!
Request timeout!
Request timeout!
Request timeout!

查看R1的路由表,可以看到因为R1上没有去往192.168.0.0/24网段的路由信息,,所以报文无法到达。

[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 15       Routes : 15       
Destination/Mask    Proto   Pre  Cost   Flags  NextHop   Interface
172.16.1.0/24       Static   80   0      RD    10.1.12.2   GigabitEthernet0/0/1

在R1上配置一条下一跳为10.1.12.2的缺省路由来实现到网络192.168.0.0/24的连通。

[R1]ip route-static 0.0.0.0 0.0.0.0 10.1.12.2

配置完成后,检测PC1到192.168.0.254网络间的连通性。

PC1>ping 192.168.0.254
Ping 192.168.0.254: 32 data bytes, Press Ctrl_C to break
From 192.168.0.254: bytes=32 seq=1 ttl=254 time=31 ms
From 192.168.0.254: bytes=32 seq=2 ttl=254 time=15 ms
From 192.168.0.254: bytes=32 seq=3 ttl=254 time=15 ms
From 192.168.0.254: bytes=32 seq=4 ttl=254 time=16 ms
From 192.168.0.254: bytes=32 seq=5 ttl=254 time=16 ms

R1通过缺省路由实现了PC1所在网段与网段192.168.0.0/24间的通信。

以下为R1的路由表信息

[R1]display ip routing-table
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 15       Routes : 15       
Destination/Mask    Proto   Pre  Cost      Flags  NextHop         Interface
    0.0.0.0/0       Static   60   0         RD   10.1.12.2       GigabitEthernet0/0/1
172.16.1.0/24       Static   80   0         RD   10.1.12.2       GigabitEthernet0/0/1

 

      步骤九 配置备份缺省路由

当R1与R2间的主链路发生故障时,R1可以使用备份缺省路由通过备份链路与192.168.0.0/24进行通信。 

在R1上配置备份缺省路由。

[R1]ip route-static 0.0.0.0 0.0.0.0 10.1.22.2 preference 80

 

      步骤十 验证备份缺省路由

关闭R1与R2上的G0/0/1接口模拟链路故障,然后查看R1的路由表。比较关闭接口前后的路由表变化情况。

[R1]interface GigabitEthernet0/0/1
[R1-GigabitEthernet0/0/1]shutdown
[R1-GigabitEthernet0/0/1]quit

在R1上查看路由表

[R1]display ip routing-table 
Route Flags: R - relay, D - download to fib
------------------------------------------------------------------------------
Routing Tables: Public
         Destinations : 12       Routes : 12       
Destination/Mask    Proto   Pre  Cost      Flags  NextHop         Interface
    0.0.0.0/0      Static   80    0          RD   10.1.22.2       GigabitEthernet0/0/2
172.16.1.0/24      Static   80    0          RD   10.1.22.2       GigabitEthernet0/0/2

上述路由表中,缺省路由0.0.0.0的Preference值为80,表明备用的缺省路由已生效。

PC1>ping 192.168.0.254
Ping 192.168.0.254: 32 data bytes, Press Ctrl_C to break
From 192.168.0.254: bytes=32 seq=1 ttl=254 time=16 ms
From 192.168.0.254: bytes=32 seq=2 ttl=254 time=32 ms
From 192.168.0.254: bytes=32 seq=3 ttl=254 time=16 ms
From 192.168.0.254: bytes=32 seq=4 ttl=254 time=16 ms
From 192.168.0.254: bytes=32 seq=5 ttl=254 time=15 ms

网络并未因为R1与R2之间的主链路被关闭而中断。在PC1上执行tracert命令,查看数据包的转发路径。

PC1>tracert 192.168.0.254
traceroute to 192.168.0.254, 8 hops max
(ICMP), press Ctrl+C to stop
 1  10.1.1.254       47 ms  <1 ms  16 ms
 2  10.1.22.2        46 ms  47 ms  16 ms
 3  192.168.0.254    31 ms  16 ms  15 ms

结果显示PC1报文到达目的地192.168.0.254通过备份链路到达。

配置文件

<R1>display current-configuration
ip route-static 0.0.0.0 0.0.0.0 10.1.12.2
ip route-static 0.0.0.0 0.0.0.0 10.1.22.2 preference 80
ip route-static 172.16.1.0 255.255.255.0 10.1.12.2
ip route-static 172.16.1.0 255.255.255.0 10.1.22.2 preference 80

<R2>display current-configuration
ip route-static 10.1.1.0 255.255.255.0 10.1.12.1
ip route-static 10.1.1.0 255.255.255.0 10.1.22.1 preference 80