一,开启DHCP功能,并且把相应端口加入VLAN,并且设置vlan网关
1.开启dhcp功能
.[Huawei]dhcp enable
2.创建vlan 10 20
[Huawei]vlan batch 10 20
3.把g0/0/1 跟g0/0/2加入到vlan10并且设置端口模式为access
[Huawei]int g 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/2]int g 0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 10
[Huawei-GigabitEthernet0/0/2]q
4.把g0/0/11 跟g0/0/12加入到vlan20并且设置端口模式为access
[Huawei]int g 0/0/11
[Huawei-GigabitEthernet0/0/11]port link-type access
[Huawei-GigabitEthernet0/0/11]port default vlan 20
[Huawei-GigabitEthernet0/0/11]int g 0/0/12
[Huawei-GigabitEthernet0/0/12]port link-type access
[Huawei-GigabitEthernet0/0/12]port default vlan 20
[Huawei-GigabitEthernet0/0/12]q
5,配置VLANIF10接口地址
[Huawei]int vlanif 10
[Huawei-Vlanif10]
[Huawei-Vlanif10]ip address 192.168.10.1 24
6.配置VLANIF20接口地址
[Huawei]int vlanif 20
[Huawei-Vlanif20]ip address 192.168.20.1 24
[Huawei-Vlanif20]q
三,配置VLANIF10接口下的终端从接口地址池中获取IP地址。
1.进入vlanif接口
[Huawei]int vlanif 10
2.客户端从此接口的DHCP地址池中获取IP地址
[Huawei-Vlanif10]dhcp select interface
3.设置dns服务器
[Huawei-Vlanif10]dhcp server dns-list 202.96.128.86
4.需要保留的ip地址
[Huawei-Vlanif10]dhcp server excluded-ip-address 192.168.10.3
5.设置租约为3天
[Huawei-Vlanif10]dhcp server lease day 3
四,配置VLANIF20接口下的终端从接口地址池中获取IP地址。
1.进入vlanif 20接口
[Huawei]int vlanif 20
2.客户端从此接口的DHCP地址池中获取IP地址
[Huawei-Vlanif20]dhcp select interface
3.设置dns服务器
[Huawei-Vlanif20]dhcp server dns-list 202.96.128.86、
4.需要保留的ip地址
[Huawei-Vlanif20]dhcp server excluded-ip-address 192.168.20.3
6.5.设置租约为3天
[Huawei-Vlanif20]dhcp server lease day 3
[Huawei-Vlanif20]q
五,验证
从下图已经看到 使用了2个地址了。
转载于:https://blog.51cto.com/557578/2177984