VRRP组网下同网段内配置基于全局地址池的DHCP服务器
组网图形
DHCP服务器简介
- 见前面DHCP服务器文章,不再赘述。
组网需求
- 如图1所示,某企业内的一台主机通过Switch双归属到SwitchA和SwitchB,SwitchA为主设备,作为DHCP服务器为客户端分配IP地址。现用户希望当主设备故障时,客户端能够通过备设备重新获取IP地址。
配置思路
- VRRP组网下同网段内配置基于全局地址池的DHCP服务器,配置思路如下:
- 1.配置SwitchA和SwitchB设备上接口IP地址,使各设备间网络层连通;同时配置Switch上的二层透传功能。
- 2.在SwitchA和SwitchB上配置VRRP备份组。其中,SwitchA上配置较高优先级,作为Master设备为客户端分配IP地址;SwitchB上配置较低优先级,作为备用交换机。
- 3.在SwitchA和SwitchB上创建全局地址池,并配置地址池相关属性。
- 4.在SwitchA、SwitchB和Switch上配置破环协议,防止环路的产生(此处以配置STP为例)。
操作步骤
- 1.配置设备间的网络互连
# 配置设备各接口的IP地址,以SwitchA为例。SwitchB的配置与SwitchA类似,不再赘述。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 | <HUAWEI> system-view [HUAWEI] sysname SwitchA [SwitchA] vlan batch 100 [SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] port link-type hybrid [SwitchA-GigabitEthernet0/0/2] port hybrid pvid vlan 100 [SwitchA-GigabitEthernet0/0/2] port hybrid untagged vlan 100 [SwitchA-GigabitEthernet0/0/2] quit [SwitchA] interface gigabitethernet 0/0/5 [SwitchA-GigabitEthernet0/0/5] port link-type hybrid [SwitchA-GigabitEthernet0/0/5] port hybrid pvid vlan 100 [SwitchA-GigabitEthernet0/0/5] port hybrid untagged vlan 100 [SwitchA-GigabitEthernet0/0/5] quit [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] ip address 10.1.1.1 24 [SwitchA-Vlanif100] quit |
# 配置Switch的二层透传功能。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | <HUAWEI> system-view [HUAWEI] sysname Switch [Switch] vlan 100 [Switch-vlan100] quit [Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] port link-type hybrid [Switch-GigabitEthernet0/0/1] port hybrid pvid vlan 100 [Switch-GigabitEthernet0/0/1] port hybrid untagged vlan 100 [Switch-GigabitEthernet0/0/1] quit [Switch] interface gigabitethernet 0/0/2 [Switch-GigabitEthernet0/0/2] port link-type hybrid [Switch-GigabitEthernet0/0/2] port hybrid pvid vlan 100 [Switch-GigabitEthernet0/0/2] port hybrid untagged vlan 100 [Switch-GigabitEthernet0/0/2] quit [Switch] interface gigabitethernet 0/0/3 [Switch-GigabitEthernet0/0/3] port link-type access [Switch-GigabitEthernet0/0/3] port default vlan 100 [Switch-GigabitEthernet0/0/3] quit |
- 2.创建地址池并配置相关属性
# 在SwitchA上启动DHCP服务。
1 | [SwitchA] dhcp enable |
# 在SwitchA上创建地址池,配置地址池范围是10.1.1.2~10.1.1.128,和SwitchB上配置的地址池地址互相排除。
1 2 | 说明: 由于交换机主设备上的地址池信息不能实时备份到备设备上,为防止主备切换后出现IP地址分配冲突,主设备和备设备上配置的地址池必须要互相排除。 |
1 2 3 4 5 6 7 | [SwitchA] ip pool 1 [SwitchA-ip-pool-1] network 10.1.1.0 mask 255.255.255.0 [SwitchA-ip-pool-1] gateway-list 10.1.1.111 [SwitchA-ip-pool-1] excluded-ip-address 10.1.1.1 [SwitchA-ip-pool-1] excluded-ip-address 10.1.1.129 10.1.1.254 [SwitchA-ip-pool-1] lease day 10 [SwitchA-ip-pool-1] quit |
# 在SwitchB上创建地址池,配置地址池范围是10.1.1.130~10.1.1.254,和SwitchA上配置的地址池地址互相排除。
1 2 3 4 5 6 7 8 | [SwitchB] dhcp enable [SwitchB] ip pool 1 [SwitchB-ip-pool-1] network 10.1.1.0 mask 255.255.255.0 [SwitchB-ip-pool-1] gateway-list 10.1.1.111 [SwitchB-ip-pool-1] excluded-ip-address 10.1.1.1 10.1.1.110 [SwitchB-ip-pool-1] excluded-ip-address 10.1.1.112 10.1.1.129 [SwitchB-ip-pool-1] lease day 10 [SwitchB-ip-pool-1] quit |
- 3.配置VRRP备份组
# 在SwitchA上创建VRRP备份组1,配置SwitchA在该备份组中的优先级为120,并配置客户端从全局地址池中获取IP地址。
1 2 3 4 5 | [SwitchA] interface vlanif 100 [SwitchA-Vlanif100] vrrp vrid 1 virtual -ip 10.1.1.111 [SwitchA-Vlanif100] vrrp vrid 1 priority 120 [SwitchA-Vlanif100] dhcp select global [SwitchA-Vlanif100] quit |
# 在SwitchB上创建VRRP备份组1,其在该备份组中的优先级为缺省值100,并配置客户端从全局地址池中获取IP地址。
1 2 3 4 | [SwitchB] interface vlanif 100 [SwitchB-Vlanif100] vrrp vrid 1 virtual -ip 10.1.1.111 [SwitchB-Vlanif100] dhcp select global [SwitchB-Vlanif100] quit |
- 4.配置STP协议,实现破除环路
# 在Switch上全局使能STP功能,SwitchA和SwitchB的配置与之类似,不再赘述。
1 | [Switch] stp enable |
# 在Switch的GE0/0/3接口上去使能STP并将端口GE0/0/1的路径开销值配置为20000。
1 2 3 4 5 6 | [Switch] interface gigabitethernet 0/0/3 [Switch-GigabitEthernet0/0/3] stp disable [Switch-GigabitEthernet0/0/3] quit [Switch] interface gigabitethernet 0/0/1 [Switch-GigabitEthernet0/0/1] stp cost 20000 [Switch-GigabitEthernet0/0/1] quit |
- 5.验证配置结果
# 完成上述配置以后,在SwitchA和SwitchB上分别执行display vrrp命令,可以看到SwitchA在备份组中的状态为Master,SwitchB在备份组中的状态为Backup。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [SwitchA] display vrrp Vlanif100 | Virtual Router 1 State : Master Virtual IP : 10.1.1.111 Master IP : 10.1.1.1 PriorityRun : 120 PriorityConfig : 120 MasterPriority : 120 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0101 Check TTL : YES Config type : normal-vrrp Backup-forward : disabled Create time : 2019-01-12 20:15:46 Last change time : 2019-01-12 20:15:46 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [SwitchB] display vrrp Vlanif100 | Virtual Router 1 State : Backup Virtual IP : 10.1.1.111 Master IP : 10.1.1.1 PriorityRun : 100 PriorityConfig : 100 MasterPriority : 120 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0101 Check TTL : YES Config type : normal-vrrp Backup-forward : disabled Create time : 2019-01-12 20:15:46 Last change time : 2019-01-12 20:15:46 |
# 在SwitchA和SwitchB上使用display ip pool命令用来查看地址池中的IP地址分配情况,可以看到作为主设备的SwitchA成功为DHCP客户端分配了IP地址,而作为备设备的SwitchB则没有为DHCP客户端分配IP地址。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [SwitchA] display ip pool ----------------------------------------------------------------------------- Pool-name : 1 Pool-No : 0 Lease : 10 Days 0 Hours 0 Minutes Position : Local Status : Unlocked Gateway-0 : 10.1.1.111 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Address Statistic: Total :253 Used :1 Idle :125 Expired :0 Conflict :0 Disable :127 IP address Statistic Total :253 Used :1 Idle :125 Expired :0 Conflict :0 Disable :127 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [SwitchB] display ip pool ----------------------------------------------------------------------------- Pool-name : 1 Pool-No : 0 Lease : 10 Days 0 Hours 0 Minutes Position : Local Status : Unlocked Gateway-0 : 10.1.1.111 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Address Statistic: Total :253 Used :0 Idle :125 Expired :0 Conflict :0 Disable :128 IP address Statistic Total :253 Used :0 Idle :125 Expired :0 Conflict :0 Disable :128 |
# 在SwitchA的接口GE0/0/2和接口GE0/0/5上执行shutdown命令,模拟SwitchA出现故障。
1 2 3 4 5 6 | [SwitchA] interface gigabitethernet 0/0/2 [SwitchA-GigabitEthernet0/0/2] shutdown [SwitchA-GigabitEthernet0/0/2] quit [SwitchA] interface gigabitethernet 0/0/5 [SwitchA-GigabitEthernet0/0/5] shutdown [SwitchA-GigabitEthernet0/0/5] quit |
# 在SwitchB上执行display vrrp命令查看VRRP状态信息,可以看到SwitchB的状态是Master。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 | [SwitchB] display vrrp Vlanif100 | Virtual Router 1 State : Master Virtual IP : 10.1.1.111 Master IP : 10.1.1.129 PriorityRun : 100 PriorityConfig : 100 MasterPriority : 100 Preempt : YES Delay Time : 0 s TimerRun : 1 s TimerConfig : 1 s Auth type : NONE Virtual MAC : 0000-5e00-0101 Check TTL : YES Config type : normal-vrrp Backup-forward : disabled Create time : 2019-01-12 20:15:46 Last change time : 2019-01-12 20:15:46 |
# 在SwitchB上使用display ip pool命令用来查看IP地址池配置情况。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | [SwitchB] display ip pool ----------------------------------------------------------------------------- Pool-name : 1 Pool-No : 0 Lease : 10 Days 0 Hours 0 Minutes Position : Local Status : Unlocked Gateway-0 : 10.1.1.111 Network : 10.1.1.0 Mask : 255.255.255.0 VPN instance : -- Address Statistic: Total :253 Used :1 Idle :124 Expired :0 Conflict :0 Disable :128 IP address Statistic Total :253 Used :1 Idle :124 Expired :0 Conflict :0 Disable :128 |
出处:https://www.cnblogs.com/zhangwencheng
版权:本文版权归作者和博客园共有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出 原文链接
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 记一次.NET内存居高不下排查解决与启示
· 探究高空视频全景AR技术的实现原理
· 理解Rust引用及其生命周期标识(上)
· 浏览器原生「磁吸」效果!Anchor Positioning 锚点定位神器解析
· 没有源码,如何修改代码逻辑?
· 分享4款.NET开源、免费、实用的商城系统
· 全程不用写代码,我用AI程序员写了一个飞机大战
· MongoDB 8.0这个新功能碉堡了,比商业数据库还牛
· 白话解读 Dapr 1.15:你的「微服务管家」又秀新绝活了
· 上周热点回顾(2.24-3.2)