拓扑图

 

实验过程

1.       pc1的预配置

Router>en

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line con 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host pc1

pc1(config)#no ip routing

pc1(config)#int e0/0

pc1(config-if)#no shut

pc1(config-if)#ip add 192.168.1.1 255.255.255.0

pc1(config-if)#exit

pc1(config)#ip default-gateway 192.168.1.254

pc1(config)#end

2.       pc2的预配置

Router>en

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line con 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host pc2

pc2(config)#no ip routing

pc2(config)#int e0/0

pc2(config-if)#no shut

pc2(config-if)#ip add 192.168.2.1 255.255.255.0

pc2(config-if)#exit

pc2(config)#ip default-gateway 192.168.2.254

pc2(config)#end

3.       R1的配置

Router>en

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line con 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R1

R1(config)#int f1/0

R1(config-if)#no shut

R1(config-if)#ip add 192.168.1.10 255.255.255.0

R1(config-if)#standby 10 ip 192.168.1.254

R1(config-if)#standby 10 preempt  

R1(config-if)#int f1/1

R1(config-if)#no shut

R1(config-if)#ip add 192.168.2.10 255.255.255.0

R1(config-if)#standby 20 ip 192.168.2.254

R1(config-if)#standby 20 pree  //开启抢占功能

R1(config-if)#standby 20 pri 150  //设置优先级

R1(config-if)#standby 20 track f1/0 80  //开启接口追踪

R1(config-if)#end

4.       R2的配置

Router#conf t

Enter configuration commands, one per line.  End with CNTL/Z.

Router(config)#no ip domain-lookup

Router(config)#line con 0

Router(config-line)#no exec-timeout

Router(config-line)#loggin syn

Router(config-line)#exit

Router(config)#host R2

R2(config)#int f1/0

R2(config-if)#no shut

R2(config-if)#ip add 192.168.1.20 255.255.255.0

R2(config-if)#standby 10 ip 192.168.1.254

R2(config-if)#standby 10 pree

R2(config-if)#standby 10 pri 150

R2(config-if)#standby 10 track f1/1 80

R2(config-if)#int f1/1

R2(config-if)#no shut

R2(config-if)#ip add 192.168.2.20 255.255.255.0

R2(config-if)#standby 20 ip 192.168.2.254

R2(config-if)#standby 20 preempt

R2(config-if)#end

5.       查看HSRP信息

R1#show standby br

                     P indicates configured to preempt.

                     |

Interface   Grp Prio P State    Active          Standby         Virtual IP    

Fa1/0     10  100   Standby   192.168.1.20 local           192.168.1.254 

Fa1/1    20  150  P Active   local           192.168.2.20    192.168.2.254

R2#show standby br

                     P indicates configured to preempt.

                     |

Interface   Grp Prio P State    Active          Standby         Virtual IP    

Fa1/0    10  150  P Active   local           192.168.1.10    192.168.1.254 

Fa1/1    20  100  Standby  192.168.2.10       local     192.168.2.254

说明:现在R1f1/1Active状态,f1/0Standby状态;R2f1/0Active状态,f1/1Standby状态。

 

6.       测试连通性

pc1#ping 192.168.2.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/36/80 ms

pc1#traceroute 192.168.2.1

 

Type escape sequence to abort.

Tracing the route to 192.168.2.1

 

  1 192.168.1.20 72 msec 32 msec 12 msec

2 192.168.2.1 8 msec *  52 msec

pc2#ping 192.168.1.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/40/92 ms

pc2#tra

pc2#traceroute 192.168.1.1

 

Type escape sequence to abort.

Tracing the route to 192.168.1.1

 

  1 192.168.2.10 28 msec 32 msec 8 msec

  2 192.168.1.1 20 msec *  28 msec

说明:现在pc1pc2R2pc2pc1R1.

 

7.       模拟故障,关闭R1f1/0接口

R1(config)#int f1/1

R1(config-if)#shut

R1(config-if)#end

R2#show standby bri

                     P indicates configured to preempt.

                     |

Interface   Grp Prio P State    Active        Standby         Virtual IP    

Fa1/0    10  150   P  Active  local       192.168.1.10    192.168.1.254 

Fa1/1      20  100  P Active   local       unknown       192.168.2.254

说明:现在R2的两个接口都变成Active状态了。

 

8.       测试连通性

pc1#ping 192.168.2.1     

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 24/43/80 ms

pc1#traceroute 192.168.2.1

 

Type escape sequence to abort.

Tracing the route to 192.168.2.1

 

  1 192.168.1.20 56 msec 48 msec 40 msec

      2 192.168.2.1 12 msec *  32 msec

pc2#ping 192.168.1.1     

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/48/76 ms

pc2#traceroute 192.168.1.1

 

Type escape sequence to abort.

Tracing the route to 192.168.1.1

 

  1 192.168.2.20 48 msec 48 msec 20 msec

      2 192.168.1.1 8 msec *  36 msec

说明:现在可以看到pc1pc2的流量都走R2.

 

9.       打开R1f1/1接口

R1(config)#int f1/1

R1(config-if)#no shut

R1(config-if)#end

R1#

R1#show standby bri

                     P indicates configured to preempt.

                     |

Interface   Grp Prio P State    Active          Standby         Virtual IP    

Fa1/0  10  100  P Standby  192.168.1.20    local           192.168.1.254 

Fa1/1  20  150  P Active   local           192.168.2.20    192.168.2.254

说明:R1抢占回了自己的f1/1接口的地位,并且优先级又加回来了。

 

10.   测试连通性

pc1#ping 192.168.2.1     

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 24/32/44 ms

pc2#ping 192.168.1.1     

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 8/36/68 ms

11.   模拟故障,关闭R2f1/0接口

R2(config)#int f1/0

R2(config-if)#shut

R2(config-if)#end

R1#show standby br

                     P indicates configured to preempt.

                     |

Interface   Grp Prio P State    Active          Standby         Virtual IP    

Fa1/0  10  100  P Active   local           unknown         192.168.1.254 

Fa1/1  20  150  P Active   local           192.168.2.20      192.168.2.254

12.   测试连通性

pc1#ping 192.168.2.1

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.2.1, timeout is 2 seconds:

.!!!!

Success rate is 80 percent (4/5), round-trip min/avg/max = 16/36/56 ms

pc1#traceroute 192.168.2.1

 

Type escape sequence to abort.

Tracing the route to 192.168.2.1

 

  1 192.168.1.10 92 msec 32 msec 20 msec

      2 192.168.2.1 12 msec *  28 msec

pc2#ping 192.168.1.1     

 

Type escape sequence to abort.

Sending 5, 100-byte ICMP Echos to 192.168.1.1, timeout is 2 seconds:

!!!!!

Success rate is 100 percent (5/5), round-trip min/avg/max = 12/43/56 ms

pc2#traceroute 192.168.1.1

 

Type escape sequence to abort.

Tracing the route to 192.168.1.1

 

  1 192.168.2.10 104 msec 28 msec 4 msec

      2 192.168.1.1 20 msec *  36 msec