HSRP+DHCP实验

HSRP+DHCP实验

拓扑图

在这里插入图片描述实验目的
1)在三层交换机上f0/1-2做三层portchannel,创建vlan 100,vlan 200,分别对应网段192.168.100.0/24 ,192.168.200.0/24
2) 两台交换机上配置HSRP ,sw1作为vlan100的主路由器,sw2作为vlan 200的主路由器
3)配置dhcp pool,是的下联pc自动获取地址

配置脚本

1.配置三层portchannel

SW1(config)#int port-channel 1
SW1(config-if)#no switchport 
SW1(config-if)#ip addr 12.1.1.1 255.255.255.0
SW1(config)#int range f0/1-2
SW1(config-if-range)#no switchport 
SW1(config-if-range)#channel-group 1 mode active 



SW2(config)#int port-channel 1
SW2(config-if)#no switchport 
SW2(config-if)#ip addr 12.1.1.2 255.255.255.0
SW2(config)#int range f0/1-2
SW2(config-if-range)#no switchport 
SW2(config-if-range)#channel-group 1 mode active 

验证:

SW2#show etherchannel su
Flags:  D - down        P - in port-channel
        I - stand-alone s - suspended
        H - Hot-standby (LACP only)
        R - Layer3      S - Layer2
        U - in use      f - failed to allocate aggregator
        u - unsuitable for bundling
        w - waiting to be aggregated
        d - default port


Number of channel-groups in use: 1
Number of aggregators:           1

Group  Port-channel  Protocol    Ports
------+-------------+-----------+----------------------------------------------

1      Po1(RU)           LACP   Fa0/1 (P ) Fa0/2(P )

2.配置HSRP

#创建vlan100 vlan200
SW1(config)#vlan 100
SW1(config-vlan)#vlan 200

#配置HSRP
SW1(config)#int range f0/3-4
SW1(config-if-range)#sw tr en do
SW1(config-if-range)#sw mo tr
SW1(config)#int f0/4
SW1(config-if)#sw tr allowed vlan 200
SW1(config-if)#int f0/3
SW1(config-if)#sw tr allowed vlan 100
二层交换机接口设置trunk


SW1(config)#int vlan 100
SW1(config-if)#ip addr 192.168.100.252 255.255.255.0
SW1(config-if)#standby 1 ip 192.168.100.254 #设置虚拟网关
SW1(config-if)#standby 1 priority 200 #设置优先级为200
SW1(config-if)#standby 1 preempt #开启抢占


SW1(config-if)#int vlan 200
SW1(config-if)#ip addr 192.168.200.253 255.255.255.0
SW1(config-if)#standby 2 ip 192.168.200.254
SW1(config-if)#standby 2 priority 195
SW1(config-if)#standby 2 preempt 
%HSRP-6-STATECHANGE: Vlan100 Grp 1 state Speak -> Standby

%HSRP-6-STATECHANGE: Vlan100 Grp 1 state Standby -> Active

%HSRP-6-STATECHANGE: Vlan200 Grp 2 state Speak -> Standby

%HSRP-6-STATECHANGE: Vlan200 Grp 2 state Standby -> Active


-----------------
SW2(config)#vlan 100
SW2(config-vlan)#vlan 200

SW2(config)#int range f0/3-4
SW2(config-if-range)#sw tr en do
SW2(config)#int vlan 100
SW2(config-if-range)#sw mo tr
SW2(config)#int f0/4
SW2(config-if)#sw tr allowed vlan 200
SW2(config-if)#int f0/3
SW2(config-if)#sw tr allowed vlan 100

SW2(config-if)#ip addr 192.168.100.253 255.255.255.0
SW2(config-if)#standby 1 ip 192.168.100.254
SW2(config-if)#standby 1 priority 195
SW2(config-if)#standby 1 preempt 
SW2(config-if)#int vlan 200
SW2(config-if)#ip addr 192.168.200.252 255.255.255.0
SW2(config-if)#standby 2 ip 192.168.200.254
SW2(config-if)#standby 2 priority 200
SW2(config-if)#standby 2 preempt 
%HSRP-6-STATECHANGE: Vlan100 Grp 1 state Speak -> Standby

%HSRP-6-STATECHANGE: Vlan100 Grp 1 state Standby -> Active

%HSRP-6-STATECHANGE: Vlan200 Grp 2 state Speak -> Standby

%HSRP-6-STATECHANGE: Vlan200 Grp 2 state Standby -> Active

%HSRP-6-STATECHANGE: Vlan100 Grp 1 state Speak -> Standby

验证:

SW2#show standby brief 
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State    Active          Standby         Virtual IP
Vl100       1    195 P Standby  192.168.100.252 local           192.168.100.254
Vl200       2    200 P Active   local           192.168.200.253 192.168.200.254


SW1#show standby brief 
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State    Active          Standby         Virtual IP
Vl100       1    200 P Active   local           192.168.100.253 192.168.100.254
Vl200       2    195 P Standby  192.168.200.252 local           192.168.200.254

## 3.配置DHCP POOL
SW1(config)#ip dhcp pool vlan100
SW1(dhcp-config)#network 192.168.100.0 255.255.255.0
SW1(dhcp-config)#default-router 192.168.100.254
SW1(dhcp-config)#dns-server 8.8.8.8
SW1(config)#ip dhcp excluded-address 192.168.100.252 192.168.100.254

SW1(dhcp-config)#network 192.168.200.0 255.255.255.0
SW1(dhcp-config)#default-router 192.168.200.254
SW1(dhcp-config)#dns-server 8.8.8.8
SW1(config)#ip dhcp excluded-address 192.168.200.252 192.168.200.254



SW2(config)#ip dhcp excluded-address 192.168.100.252 192.168.100.254
SW2(config)#ip dhcp excluded-address 192.168.200.252 192.168.200.254
SW2(config)#ip dhcp pool vlan100
SW2(dhcp-config)# network 192.168.100.0 255.255.255.0
SW2(dhcp-config)# default-router 192.168.100.254
SW2(dhcp-config)# dns-server 8.8.8.8
SW2(dhcp-config)#ip dhcp pool vlan200
SW2(dhcp-config)# network 192.168.200.0 255.255.255.0
SW2(dhcp-config)# default-router 192.168.200.254

验证

关闭sw1,验证是否能够ping通网关

SW1(config)#int range f0/1-4
SW1(config-if-range)#shut


SW2#show standby brief 
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State    Active          Standby         Virtual IP
Vl100       1    195 P Active   local           unknown         192.168.100.254
Vl200       2    200 P Active   local           192.168.200.253 192.168.200.254



C:\>ping 192.168.100.254

Pinging 192.168.100.254 with 32 bytes of data:

Reply from 192.168.100.254: bytes=32 time<1ms TTL=255
Reply from 192.168.100.254: bytes=32 time=1ms TTL=255
Reply from 192.168.100.254: bytes=32 time<1ms TTL=255
Reply from 192.168.100.254: bytes=32 time<1ms TTL=255

开启sw1

SW1(config-if-range)#no shut


SW1#show standby brief 
                     P indicates configured to preempt.
                     |
Interface   Grp  Pri P State    Active          Standby         Virtual IP
Vl100       1    200 P Active   local           192.168.100.253 192.168.100.254
Vl200       2    195 P Standby  192.168.200.252 local           192.168.200.254

猜你喜欢

转载自blog.csdn.net/weixin_41566700/article/details/86536724