华为5700交换机DHCP基础配置案例
配置两个地址池:192.168.1.0/24和192.168.2.0/24
配置两个VLAN:10和20
将四台主机分别加入VLAN
自动获取IP地址,确保全网互通。
步骤:
在DHCP交换机上创建VLAN10,20;IP地址池VLAN 10和IP地址池 VLAN 20
[DHCP]DHCP enable //打开DHCP功能
[DHCP]vlan batch 10 20 //创建两个Vlan 10和20
[DHCP]ip pool vlan10 //新增地址池名称为 Vlan10
[DHCP]gateway-list 192.168.1.254 //设置网关
[DHCP]network 192.168.1.0 mask 255.255.255.0 //设置地址段
[DHCP]excluded-ip-address 192.168.1.200 192.168.1.253 //可以设置排除IP范围
[DHCP]lease day 5 //设置获取到IP地址的有效期为5天
[DHCP]dns-list 114.114.114.114 //设置客户机DNS,多条命令可设置多个
[DHCP]ip pool VLAN 20 //新增地址池名称为 Vlan20
[DHCP]gateway-list 192.168.2.254 //设置网关
[DHCP]network 192.168.2.0 mask 255.255.255.0 //设置地址池
[DHCP]excluded-ip-address 192.168.2.100 192.168.1.200 //可以设置排除IP范围
[DHCP]lease day 5 //设置获取到IP地址的有效期为5天
[DHCP]dns-list 8.8.8.8 //设置客户机DNS,多条命令可设置多个
分配vlanif 端口配置
[DHCP]interface vlanif10 //进入vlanif10接口
[DHCP]ip address 192.168.1.254 255.255.255.0 //配置接口IP
[DHCP]dhcp select global
[DHCP] interface vlanif20 //进入vlanif10接口
[DHCP]ip address 192.168.2.254 255.255.255.0 //配置接口IP
[DHCP]dhcp select global
给DHCP服务器1口和2口配置trunk链路
[DHCP]interface g0/0/1
[DHCP]port link-type trunk
[DHCP]port trunk allow-pass Vlan 10
[DHCP]interface g0/0/2
[DHCP]port link-type trunk
[DHCP]port trunk allow-pass Vlan 20
二、SW1交换机上
[SW1]DHCP enable //打开DHCP功能
在交换机一上把端口1;2加入VLAN 10;端口3设置成trunk链路
[SW1]vlan batch 10 //创建两个Vlan 10
[SW1]interface g0/0/1 //进入接口1
[SW1]port link-type access //配置接口类型为access
[SW1]port default vlan 10 //接口配置属于Vlan10
[SW1]interface g0/0/2 //进入接口2
[SW1]port link-type access //配置接口类型access
[SW1]port default vlan 10 //接口配置属于Vlan10
[SW1]interface g0/0/3 //进入接口3
[SW1]port link-type trunk //配置接口类型trunk
[SW1]port trunk allow-pass vlan 10 //配置哪些Vlan充许通过
三、SW2交换机上也做相同操作
验证测试保存