【DHCP实验】使用三层交换机配置DHCP Server服务器(基于全局地址池配置)

本文涉及的产品
云解析 DNS,旗舰版 1个月
全局流量管理 GTM,标准版 1个月
公共DNS(含HTTPDNS解析),每月1000万次HTTP解析
简介: 【DHCP实验】使用三层交换机配置DHCP Server服务器(基于全局地址池配置)

一、实验拓扑

f04acda16878410fb343d8b481aee0a5.png

二、实验要求

三层交换机S1通过DHCP的公有地址池给PC1和PC2分配IP地址,PC1属于vlan30,PC2属于vlan40,具体要求如下:

(1) 更改主机名S1

(2) 创建vlan 30 40

(3) 配置vlanif 30接口的IP地址为192.168.30.254,vlanif 40接口的IP地址为192.168.40.254

(4) 配置access接口

(5) 启用DHCP

(6) 配置全局地址池

地址池1名:dhcp_vlan30

地址网段:192.168.30.0/24

网关:192.168.30.254

DNS服务器地址:114.114.114.114和 8.8.8.8

地址池2名:dhcp_vlan40

地址网段:192.168.40.0/24

网关:192.168.40.254

DNS服务器地址:114.114.114.114和 8.8.8.8

(7) 配置vlanif 30和vlanif40虚接口下启用全局地址池


三、实验步骤

(1) 更改主机名S1
The device is running!
<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.  
[Huawei]undo info-center enable 
Info: Information center is disabled. 
[Huawei]sysname S1
[S1]
(2) 创建vlan 30 40
[S1]vlan batch 30 40
Info: This operation may take a few seconds. Please wait for a moment...done.
[S1]
(3) 配置vlanif 30接口的IP地址为192.168.30.254,vlanif 40接口的IP地址为192.168.40.254
!!!注意配置接口IP地址与配置端口access时的先后顺序,应先创建并配置vlan以及接口IP地址,再将各个端口加入相应的vlan中,否则vlan端口启动不了!!!
[S1]interface Vlanif 30
[S1-Vlanif30]ip address 192.168.30.254 24
[S1-Vlanif30]display this
#
interface Vlanif30
 ip address 192.168.30.254 255.255.255.0
#
return
[S1-Vlanif30]quit 
[S1]interface Vlanif 40
[S1-Vlanif40]ip address 192.168.40.254 24
[S1-Vlanif40]display this
#
interface Vlanif40
 ip address 192.168.40.254 255.255.255.0
#
return
[S1-Vlanif40]quit 
[S1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 2
The number of interface that is DOWN in Physical is 3
The number of interface that is UP in Protocol is 1
The number of interface that is DOWN in Protocol is 4
Interface                         IP Address/Mask      Physical   Protocol  
MEth0/0/1                         unassigned           down       down      
NULL0                             unassigned           up         up(s)     
Vlanif1                           unassigned           up         down      
Vlanif30                          192.168.30.254/24    down       down      
Vlanif40                          192.168.40.254/24    down       down      
[S1]
(4) 配置access接口
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]port link-type access    
[S1-GigabitEthernet0/0/1]port default vlan 30
[S1-GigabitEthernet0/0/1]display this
#
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 30
#
return
[S1-GigabitEthernet0/0/1]quit
[S1]interface GigabitEthernet 0/0/3
[S1-GigabitEthernet0/0/3]port link-type access  
[S1-GigabitEthernet0/0/3]port default vlan 40
[S1-GigabitEthernet0/0/3]display this
#
interface GigabitEthernet0/0/3
 port link-type access
 port default vlan 40
#
return
[S1-GigabitEthernet0/0/3]quit
[S1]display ip interface brief 
*down: administratively down
^down: standby
(l): loopback
(s): spoofing
The number of interface that is UP in Physical is 3
The number of interface that is DOWN in Physical is 2
The number of interface that is UP in Protocol is 3
The number of interface that is DOWN in Protocol is 2
Interface                         IP Address/Mask      Physical   Protocol  
MEth0/0/1                         unassigned           down       down      
NULL0                             unassigned           up         up(s)     
Vlanif1                           unassigned           down       down      
Vlanif30                          192.168.30.254/24    up         up        
Vlanif40                          192.168.40.254/24    up         up        
[S1]
(5) 启用DHCP
[S1]dhcp enable 
[S1]
(6) 配置全局地址池
     地址池1名:dhcp_vlan30
     地址网段:192.168.30.0/24
     网关:192.168.30.254
     DNS服务器地址:114.114.114.114和 8.8.8.8
     地址池2名:dhcp_vlan40
     地址网段:192.168.40.0/24
     网关:192.168.40.254
     DNS服务器地址:114.114.114.114和 8.8.8.8
[S1]ip pool dhcp_vlan30
Info:It's successful to create an IP address pool.  
[S1-ip-pool-dhcp_vlan30]network 192.168.30.0 mask 24  
[S1-ip-pool-dhcp_vlan30]gateway-list 192.168.30.254 
[S1-ip-pool-dhcp_vlan30]dns-list 114.114.114.114 8.8.8.8
[S1-ip-pool-dhcp_vlan30]display this
#
ip pool dhcp_vlan30
 gateway-list 192.168.30.254
 network 192.168.30.0 mask 255.255.255.0
 dns-list 114.114.114.114 8.8.8.8
#
return
[S1-ip-pool-dhcp_vlan30]quit
[S1]ip pool dhcp_vlan40
Info:It's successful to create an IP address pool.
[S1-ip-pool-dhcp_vlan40]network 192.168.40.0 mask 24
[S1-ip-pool-dhcp_vlan40]gateway-list 192.168.40.254
[S1-ip-pool-dhcp_vlan40]dns-list 114.114.114.114 8.8.8.8
[S1-ip-pool-dhcp_vlan40]display this
#
ip pool dhcp_vlan40
 gateway-list 192.168.40.254
 network 192.168.40.0 mask 255.255.255.0
 dns-list 114.114.114.114 8.8.8.8
#
return
[S1-ip-pool-dhcp_vlan40]quit
[S1]display ip pool 
  -----------------------------------------------------------------------
  Pool-name      : dhcp_vlan30
  Pool-No        : 0
  Position       : Local           Status           : Unlocked
  Gateway-0      : 192.168.30.254  
  Mask           : 255.255.255.0
  VPN instance   : --
  -----------------------------------------------------------------------
  Pool-name      : dhcp_vlan40
  Pool-No        : 1
  Position       : Local           Status           : Unlocked
  Gateway-0      : 192.168.40.254  
  Mask           : 255.255.255.0
  VPN instance   : --
  IP address Statistic
    Total       :506   
    Used        :0          Idle        :506   
    Expired     :0          Conflict    :0          Disable   :0     
[S1]
(7) 配置vlanif 30和vlanif40虚接口下启用全局地址池
[S1]interface Vlanif 30 
[S1-Vlanif30]dhcp select global 
[S1-Vlanif30]display this
#
interface Vlanif30
 ip address 192.168.30.254 255.255.255.0
 dhcp select global
#
return
[S1-Vlanif30]quit
[S1]interface Vlanif 40
[S1-Vlanif40]dhcp select global
[S1-Vlanif40]display this
#
interface Vlanif40
 ip address 192.168.40.254 255.255.255.0
 dhcp select global
#
return
[S1-Vlanif40]quit
[S1]display ip pool name dhcp_vlan30 
  Pool-name      : dhcp_vlan30
  Pool-No        : 0
  Lease          : 1 Days 0 Hours 0 Minutes
  Domain-name    : -
  DNS-server0    : 114.114.114.114 
  DNS-server1    : 8.8.8.8        
  NBNS-server0   : -               
  Netbios-type   : -               
  Position       : Local           Status           : Unlocked
  Gateway-0      : 192.168.30.254  
  Mask           : 255.255.255.0
  VPN instance   : --
 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
    192.168.30.1  192.168.30.254   253     1        252(0)         0        0
 -----------------------------------------------------------------------------
[S1]
[S1]display ip pool name dhcp_vlan40 
  Pool-name      : dhcp_vlan40
  Pool-No        : 1
  Lease          : 1 Days 0 Hours 0 Minutes
  Domain-name    : -
  DNS-server0    : 114.114.114.114 
  DNS-server1    : 8.8.8.8         
  NBNS-server0   : -               
  Netbios-type   : -               
  Position       : Local           Status           : Unlocked
  Gateway-0      : 192.168.40.254  
  Mask           : 255.255.255.0
  VPN instance   : --
 -----------------------------------------------------------------------------
         Start           End     Total  Used  Idle(Expired)  Conflict  Disable
 -----------------------------------------------------------------------------
    192.168.40.1  192.168.40.254   253     1        252(0)         0        0
 -----------------------------------------------------------------------------
[S1]
(8)保存S1交换机上的配置文件
[S1]q
<S1>save
The current configuration will be written to the device.
Are you sure to continue?[Y/N]y
Now saving the current configuration to the slot 0.
Save the configuration successfully.
<S1>


四、实验测试

执行ipconfig命令

执行ipconfig /release ——释放获取到的IP地址参数

执行ipconfig /renew——获取新的IP地址参数

f0f3646ec2a54d81a3f14e11c648f871.png

698d1bde614446e5adea0d87a64c842b.png

PC1

PC>ipconfig /release
IP Configuration
Link local IPv6 address...........: fe80::5689:98ff:fe79:248a
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 0.0.0.0
Subnet mask.......................: 0.0.0.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-79-24-8A
DNS server........................:
PC>ipconfig /renew
IP Configuration
Link local IPv6 address...........: fe80::5689:98ff:fe79:248a
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.30.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.30.254
Physical address..................: 54-89-98-79-24-8A
DNS server........................: 114.114.114.114
                                    8.8.8.8
PC>


PC2

PC>ipconfig /release
IP Configuration
Link local IPv6 address...........: fe80::5689:98ff:fe99:4726
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 0.0.0.0
Subnet mask.......................: 0.0.0.0
Gateway...........................: 0.0.0.0
Physical address..................: 54-89-98-99-47-26
DNS server........................:
PC>ipconfig /renew
IP Configuration
Link local IPv6 address...........: fe80::5689:98ff:fe99:4726
IPv6 address......................: :: / 128
IPv6 gateway......................: ::
IPv4 address......................: 192.168.40.253
Subnet mask.......................: 255.255.255.0
Gateway...........................: 192.168.40.254
Physical address..................: 54-89-98-99-47-26
DNS server........................: 114.114.114.114
                                    8.8.8.8
PC>


相关文章
|
15天前
|
存储 弹性计算 人工智能
2025年阿里云企业云服务器ECS选购与配置全攻略
本文介绍了阿里云服务器的核心配置选择方法论,涵盖算力需求分析、网络与存储设计、地域部署策略三大维度。针对不同业务场景,如初创企业官网和AI模型训练平台,提供了具体配置方案。同时,详细讲解了购买操作指南及长期运维优化建议,帮助用户快速实现业务上云并确保高效运行。访问阿里云官方资源聚合平台可获取更多最新产品动态和技术支持。
|
14天前
|
存储 人工智能 缓存
怎么根据自己的业务选择阿里云服务器配置大小?
本文指导如何根据业务需求精准选择阿里云服务器配置,涵盖个人轻量级至企业级、计算密集型等场景,推荐不同实例类型、存储与带宽方案,并提供成本优化策略,如包年包月节省成本、按需升级配置及选用性价比高的自研ARM架构实例。帮助用户在数字化转型中实现性能与成本的平衡。 注:以上配置与价格基于阿里云2025年官方数据,实际信息可能有所调整,请以官网实时页面为准。
|
14天前
|
人工智能 运维 监控
2025年阿里云服务器配置选择全攻略:CPU、内存、带宽与系统盘详解
在2025年,阿里云服务器以高性能、灵活扩展和稳定服务助力数字化转型,提供轻量应用服务器、通用型g8i实例等多样化配置,满足个人博客至企业级业务需求。针对不同场景(如计算密集型、内存密集型),推荐相应实例类型与带宽规划,强调成本优化策略,包括包年包月节省成本、ESSD云盘选择及地域部署建议。文中还提及安全设置、监控备份的重要性,并指出未来可关注第九代实例g9i支持的新技术。整体而言,阿里云致力于帮助用户实现性能与成本的最优平衡。 以上简介共计238个字符。
|
7天前
|
存储 安全 网络安全
阿里云国际站:阿里云服务器端口配置
悟空云@CloudWuKong阿里云是全球领先的云计算服务提供商,为用户提供弹性计算、数据库、存储、网络安全等一系列云计算服务。在使用阿里云服务器时,合理配置端口非常重要,可以提高服务器安全性和稳定性。
|
14天前
|
存储 人工智能 监控
新手小白购买阿里云服务器省钱策略、配置选型与注意事项
针对初次使用阿里云服务器的用户,本文提供系统化的指导方案以优化成本并满足业务需求。首先介绍配置选型,包括实例类型(通用型、计算型、内存型)与基础配置建议;其次阐述省钱策略,如企业认证、合理选择计费模式及批量购买;最后提醒注意事项,涵盖带宽存储规划、地域网络优化及安全管理。新手可通过明确需求、选择配置、优化购买和持续监控四步快速上手,实现高效稳定的云端部署。 注:推荐配置基于2025年阿里云产品体系,具体信息请参考官网。
|
4月前
|
安全 网络协议 网络安全
Cisco-DHCP配置
Cisco-DHCP配置
114 3
|
12天前
|
域名解析 网络协议 Ubuntu
DHCP与DNS的配置
通过这些步骤,您可以在Linux环境下成功配置和验证DHCP和DNS服务。希望这些内容对您的学习和工作有所帮助。
69 27
|
4月前
|
安全 小程序 网络安全
Cisco-DHCP中继配置
Cisco-DHCP中继配置
133 4
|
5月前
|
Linux
kickstart自动安装系统 --DHCP 配置及测试
PXE+Kickstart自动安装系统需配置DHCP服务器分配IP。dhcpd.conf示例:设置更新样式、忽略客户端更新、指定下一服务器及启动文件。定义子网、网关、掩码、动态地址池并预留特定MAC地址。重启xinetd、NFS、DHCP服务,确保新服务器与Kickstart服务器在同一网络,避免误装其他机器。注意隔离测试网络以防干扰生产环境。
97 18
|
6月前
|
安全 Ubuntu 网络协议
在Linux中,如何配置DHCP服务器?
在Linux中,如何配置DHCP服务器?

热门文章

最新文章