实验拓扑:
最简单的dhcp配置:
pc1和pc2放在同一vlan中,两台电脑都设置为DHCP模式
对交换机的配置:
<Huawei>sys //进入系统视图
Enter system view, return user view with Ctrl+Z.
[Huawei]sys S1 //设备改名
[S1]
Apr 21 2022 16:54:07-08:00 S1 DS/4/DATASYNC_CFGCHANGE:OID 1.3.6.1.4.1.2011.5.25.
191.3.1 configurations have been changed. The current change number is 4, the ch
ange loop count is 0, and the maximum number of records is 4095.
[S1]un in en //关闭提示信息
Info: Information center is disabled.
[S1]dhcp enable //命令用来开启DHCP功能
Info: The operation may take a few seconds. Please wait for a moment.done.
[S1]ip pool pool10 //创建全局地址池
Info:It's successful to create an IP address pool.
[S1-ip-pool-pool10]network 192.168.1.0 mask 24
//用来配置全局地址池下可分配的网段地址,其中mask:指定IP地址池的网络掩码,不指定该参数时,使用自然掩码
[S1-ip-pool-pool10]gateway-list 192.168.1.1
//用来为DHCP Client配置出口网关地址
[S1-ip-pool-pool10]lease day 99 //设置生存时间
[S1-ip-pool-pool10]quit
[S1]vlan 10 //下面是交换机的vlan配置过程
[S1-vlan10]q
[S1-vlan10]int G0/0/1
[S1-GigabitEthernet0/0/1]port link-type access
[S1-GigabitEthernet0/0/1]port default vlan 10
[S1-GigabitEthernet0/0/1]int G0/0/2
[S1-GigabitEthernet0/0/2]port link-type access
[S1-GigabitEthernet0/0/2]port default vlan 10
[S1-GigabitEthernet0/0/2]q
[S1]int Vlanif 10 //进入交换机虚拟接口,前面一定要先创建vlan
[S1-Vlanif10]ip add 192.168.1.1 24 //为接口配置IP
[S1-Vlanif10]dhcp select global //用来开启接口采用全局地址池的DHCP Server功能
结果:
在两台pc机中各自使用ipconfig查看IP,发现IP已经自动分配。
(交换机配置没保存,不想再敲一遍了,所以就没有图了)