一,实验要求:

1PC1属于vlan 10vlan 10的成员从SW1端口的f1/10过,且M1上的某个接口断开,则从SW1端口的f1/11HSRP

2PC2属于vlan 20vlan 20的成员从SW1端口的f1/11过,且M2上的某个接口断开,则从SW1端口的f1/10VRRP

3,在R1上做浮动路由,任意端口断开,则从另一端口走

二,实验目的(掌握):

1,三层交换技术

2HSRPVRRP技术

3vlan技术

三,实验拓扑:

HSRP(热备份路由选择协议)与VRRP(虚拟路由器冗余协议)_路由选择协议

SW1配置:

SW1#conf t

SW1(config)#no ip routing

SW1(config)#vlan 10

SW1(config-vlan)#vlan 20

SW1(config-vlan)#int f1/1

SW1(config-if)#switchport access vlan 10

SW1(config-if)#no shut

SW1(config-if)#int f1/2

SW1(config-if)#switchport access vlan 20

SW1(config-if)#no shut

SW1(config)#int range f1/10 -11

SW1(config-if-range)#no shut

SW1(config-if-range)#do show run

interface FastEthernet1/1

switchport access vlan 10

!

interface FastEthernet1/2

switchport access vlan 20

!

!

interface FastEthernet1/10

switchport mode trunk

!

interface FastEthernet1/11

switchport mode trunk

M1配置:

M1#conf t

M1(config)#vlan 10

M1(config-vlan)#vlan 20

M1(config)#int f1/10

M1(config-if)#switchport mode trunk

M1(config-if)#no shut

M1(config-if)#ex

M1(config)#int vlan 10

M1(config-if)#ip add 192.168.10.10 255.255.255.0

M1(config-if)#standby 1 ip 192.168.10.1 //虚拟ip地址    HSRP

M1(config-if)#standby 1 priority 150 //优先级为150      

M1(config-if)#standby 1 preempt  //占先权            活跃

M1(config-if)#standby 1 track f1/10 10 //端口跟踪        路由器

M1(config-if)#standby 1 track f0/0 10

M1(config-if)#no shut

M1(config)#int f0/0

M1(config-if)#ip add 202.106.1.1 255.255.255.252

M1(config-if)#no shut

M1(config-if)#ex

M1(config)#int loopback 0

M1(config-if)#ip add 8.8.8.8 255.255.255.255

M1(config-if)#no shut

M1(config-if)#ex

M1(config)#ip route 0.0.0.0 0.0.0.0 202.106.1.2

M1(config)#do show standby b //查看HSRP的消息

Interface Grp  Pri P State   Active          Standby         Virtual IP

Vl10      1    150 P Active  local           192.168.10.20   192.168.10.1

HSRP(热备份路由选择协议)与VRRP(虚拟路由器冗余协议)_HSRP_02

M1(config)#int vlan 10

M1(config-if)#standby 1 priority 135 //改优先权

M1(config-if)#do show standby b(结论)

P indicates configured to preempt.

                  |

Interface Grp  Pri P State   Active          Standby         Virtual IP

Vl10      1    135 P Standby 192.168.10.20   local           192.168.10.1

HSRP(热备份路由选择协议)与VRRP(虚拟路由器冗余协议)_HSRP_03

M1(config)#int vlan 20

M1(config-if)#ip add 192.168.20.20 255.255.255.0

M1(config-if)#vrrp 2 ip 192.168.20.1 //虚拟ip   VRRP

M1(config-if)#vrrp 2 preempt //占先权         备份

M1(config-if)#vrrp 2 priority 115//优先级       路由

M1(config-if)#no shut

M1(config)#do show vrrp b

Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

Vl20               2   115 3550       Y  Init    0.0.0.0         192.168.20.1

M1#show run

track 3 interface FastEthernet1/10 line-protocol

track 4 interface FastEthernet0/0 line-protocol

!

interface FastEthernet0/0

ip address 202.106.1.1 255.255.255.252

interface FastEthernet1/10

switchport mode trunk

!

interface Vlan10

ip address 192.168.10.10 255.255.255.0

standby 1 ip 192.168.10.1

standby 1 priority 130

standby 1 preempt

standby 1 track FastEthernet1/10

standby 1 track FastEthernet0/0

!

interface Vlan20

ip address 192.168.20.20 255.255.255.0

vrrp 2 ip 192.168.20.1

vrrp 2 priority 115

!

ip route 0.0.0.0 0.0.0.0 202.106.1.2

!

M2配置:

M2#conf t

M2(config)#vlan 10

M2(config-vlan)#vlan 20

M2(config-vlan)#ex

M2(config)#int f1/11

M2(config-if)#switchport mode trunk

M2(config-if)#no shut

M2(config-if)#ex

M2(config)#int vlan 10                               HSRP

M2(config-if)#ip add 192.168.10.20 255.255.255.0          

M2(config-if)#standby 1 ip 192.168.10.1                  备份

M2(config-if)#standby 1 priority 140                     路由

M2(config-if)#standby 1 preempt

M2(config-if)#no shut

M2(config-if)#ex

M2(config)#int f0/0

M2(config-if)#ip add 202.106.2.1 255.255.255.252

M2(config-if)#no shut

M2(config-if)#ex

M2(config)#ip route 0.0.0.0 0.0.0.0 202.106.2.2

M2(config)#do show standby b

   P indicates configured to preempt.

                  |

Interface Grp  Pri P State   Active          Standby         Virtual IP

Vl10      1    140 P Standby 192.168.10.10   local           192.168.10.1

M2(config)#track 1 int f1/11 line-protocol //跟踪端口1       VRRP

M2(config-track)#track 2 int f0/0 line-protocol//跟踪端口2      

M2(config)#int vlan 20

M2(config-if)#ip add 192.168.20.10 255.255.255.0

M2(config-if)#vrrp 2 ip 192.168.20.1 //                      

M2(config-if)#vrrp 2 priority 120                          路由

M2(config-if)#vrrp 2 preempt                             配置

M2(config-if)#vrrp 2 track 1//跟踪端口1

M2(config-if)#vrrp 2 track 2//跟踪端口2

M2(config-if)#no shut

M2(config-if)#do show vrrp b //查看VRRP消息

Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

Vl20               2   120 3531       Y  Master  192.168.20.10   192.168.20.1

HSRP(热备份路由选择协议)与VRRP(虚拟路由器冗余协议)_VRRP_04

M2(config)#int vlan 20

M2(config-if)#vrrp 2 priority 100(改优先权)

M2(config-if)#do show vrrp b(结论)

Interface          Grp Pri Time  Own Pre State   Master addr     Group addr

Vl20               2   100 3453       Y  Backup  192.168.20.20   192.168.20.1

HSRP(热备份路由选择协议)与VRRP(虚拟路由器冗余协议)_路由选择协议_05

M2(config-if)#do show run

interface FastEthernet0/0

ip address 202.106.2.1 255.255.255.252

!

interface FastEthernet1/11

switchport mode trunk

!

interface Vlan10

ip address 192.168.10.20 255.255.255.0

standby 1 ip 192.168.10.1

standby 1 priority 140

standby 1 preempt

!

interface Vlan20

ip address 192.168.20.10 255.255.255.0

vrrp 2 ip 192.168.20.1

vrrp 2 priority 120

vrrp 2 track 1

vrrp 2 track 2

!

ip route 0.0.0.0 0.0.0.0 202.106.2.2

!

R1配置:

R1#conf t

R1(config)#int f0/0

R1(config-if)#ip add 202.106.1.2 255.255.255.252

R1(config-if)#no shut

R1(config-if)#int f0/1

R1(config-if)#ip add 202.106.2.2 255.255.255.252

R1(config-if)#no shut

R1(config-if)#ex

R1(config)#int loopback 0

R1(config-if)#ip add 8.8.8.8 255.255.255.0

R1(config-if)#no shut

R1(config-if)#ex

R1(config)#ip route 192.168.10.0 255.255.255.0 202.106.1.1        

R1(config)#ip route 192.168.10.0 255.255.255.0 202.106.2.1 10      

R1(config)#ip route 192.168.20.0 255.255.255.0 202.106.2.1        

R1(config)#ip route 192.168.20.0 255.255.255.0 202.106.1.1 10      

R1#show run

interface Loopback0

ip address 8.8.8.8 255.255.255.0

!

interface FastEthernet0/0

ip address 202.106.1.2 255.255.255.252

!

interface FastEthernet0/1

ip address 202.106.2.2 255.255.255.252

!

ip route 192.168.10.0 255.255.255.0 202.106.1.1

ip route 192.168.10.0 255.255.255.0 202.106.2.1 10

ip route 192.168.20.0 255.255.255.0 202.106.2.1

ip route 192.168.20.0 255.255.255.0 202.106.1.1 10

!