<Huawei>system-view 在用户模式下输入 `system-view` 来切换到系统模式。
[Huawei]sysname layer3 Switch 给交换机起一个名字。
[layer3 Switch]undo info-center enable 关闭提示信息。
第一步:创建VLAN10、20
[layer3 Switch]vlan batch vlan 10 20 创建VLAN 10、20。
第二步:配置DHCP服务
动态主机配置协议,用来分配IP地址等网络参数。 用户上网需要的条件:IP地址,网关,DNS… 注意:除非有特殊需求会采用静态配置(员工比较多的企业)。路由器、核心交换机、Linux、服务器等上面都可以配置DHCP。
[layer3 Switch]dhcp enable 开启DHCP服务。
第三步:进入VLANIF 10 配置网关地址并采用DHCP全局模式
[layer3 Switch]interface vlanif10 进入vlanif20
[layer3 Switch] ip address 192.168.10.1 255.255.255.0 设置网关地址。
[layer3 Switch-Vlanif10]dhcp select global 开启全局模式。
第四步:进入VLANIF 20 配置网关地址并采用DHCP全局模式
[layer3 Switch-Vlanif10]interface vlanif20 进入vlanif20
[layer3 Switch-Vlanif20]ip address 192.168.20.1 24 设置网关地址。
[layer3 Switch-Vlanif20]dhcp select global 开启全局模式。
[layer3 Switch-Vlanif20]quit 退出。
第五步:创建地址池
[layer3 Switch]ip pool vlan10 创建VLAN10地址池。
[layer3 Switch-ip-pool-vlan10]network 192.168.10.0 mask 24 宣告网段。
[layer3 Switch-ip-pool-vlan10]gateway-list 192.168.10.1 设置网关。
[layer3 Switch-ip-pool-vlan10]dns-list 114.114.114.114 8.8.8.8 设置主、备选DNS。
[layer3 Switch-ip-pool-vlan10]excluded-ip-address 192.168.10.200 192.168.10.254 保留一部分IP地址供打印机、服务器等终端使用
[layer3 Switch-ip-pool-vlan10]quit VLAN10的地址池就创建好了。
[layer3 Switch]ip pool vlan20 创建VLAN20地址池。
[layer3 Switch-ip-pool-vlan20]network 192.168.20.0 mask 24 宣告网段。
[layer3 Switch-ip-pool-vlan20]gateway-list 192.168.20.1 设置网关。
[layer3 Switch-ip-pool-vlan20]dns-list 114.114.114.114 8.8.8.8 设置主、备选DNS。
[layer3 Switch-ip-pool-vlan20]excluded-ip-address 192.168.20.200 192.168.20.254 保留一部分IP地址供打印机、服务器等终端使用
[layer3 Switch-ip-pool-vlan10]quit VLAN20的地址池就创建好了。
第六步:将接口加入到VLAN
[layer3 Switch-GigabitEthernet0/0/1]port link-type access
[layer3 Switch-GigabitEthernet0/0/1]port default vlan 10
[layer3 Switch-GigabitEthernet0/0/2]port link-type access
[layer3 Switch-GigabitEthernet0/0/2]port default vlan 20
以上配置均完成后,部门A与部门B就可以自动获取各自的IP地址了。
更改IP地址的租用时间。(一般不改)
[Huawei-ip-pool-aa]lease day 0 hour 20
通过地址绑定的方式实现:固定IP。
[Huawei-ip-pool-aa]static-bind ip-address 10.1.1.100 mac-address 5489-986E-7237
查看DHCP地址池分配IP地址的记录。
[Huawei]dis ip pool name aa used
PC>ipconfig /release:释放IP地址。 PC>ipconfig /renew :重新获取IP地址
将部分IP地址排出地址池,用于静态IP配置
[Huawei-ip-pool-aa]excluded-ip-address 10.1.1.120 10.1.1.200
重置分配IP: reset ip pool name aa used. 查看:dis ip pool name aa