HSRP搶佔和接口追蹤

拓撲圖

 

實驗過程

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

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章