华为交换机配置DHCP

手动配置IP

华为交换机配置DHCP_第1张图片
划分VLAN10、20 ,并将端口1放入VLAN10,端口2放入VLAN20。

<Huawei>system-view 
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]interface vlanif 10
[Huawei-Vlanif10]ip address 192.168.10.254 24
[Huawei-Vlanif10]interface vlanif 20
[Huawei-Vlanif20]ip address 192.168.20.254 24
[Huawei-Vlanif20]interface gigabitethernet 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]interface gigabitethernet 0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 20
[Huawei-GigabitEthernet0/0/2]

给PC1、PC2手动分配地址
华为交换机配置DHCP_第2张图片
华为交换机配置DHCP_第3张图片
最后两台PC相互ping一下看是否相通
华为交换机配置DHCP_第4张图片
华为交换机配置DHCP_第5张图片

基于端口DHCP配置

华为交换机配置DHCP_第6张图片
全局模式下开启DHCP
划分VLAN10、20,并将端口g0/0/1、g0/0/2分配相应VLAN
指定VLAN10、20网关
指定基于端口DHCP
指定dns
指定租期
排除分配地址范围

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[Huawei]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]interface gigabitethernet 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]interface gigabitethernet 0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 20
[Huawei-GigabitEthernet0/0/2]q
[Huawei]interface vlanif 10
[Huawei-Vlanif10]ip address 192.168.10.254 24
[Huawei-Vlanif10]dhcp select interface
[Huawei-Vlanif10]dhcp server dns-list 1.1.1.1
[Huawei-Vlanif10]dhcp server lease day 1
[Huawei-Vlanif10]dhcp excluded-ip-address 192.168.10.100 192.168.10.253
                      ^
Error: Unrecognized command found at '^' position.
[Huawei-Vlanif10]dhcp server excluded-ip-address 192.168.10.100 192.168.10.253
[Huawei-Vlanif10]q
[Huawei]interface vlanif 20
[Huawei-Vlanif20]ip address 192.168.20.254 24
[Huawei-Vlanif20]dhcp select interface
[Huawei-Vlanif20]dhcp server dns-list 2.2.2.2
[Huawei-Vlanif20]dhcp server lease day 2
[Huawei-Vlanif20]dhcp server excluded-ip-address 192.168.20.100 192.168.20.253
[Huawei-Vlanif20]q
[Huawei]

将PC1、PC2的DHCP开启
华为交换机配置DHCP_第7张图片
华为交换机配置DHCP_第8张图片
在命令行里查询IP以及相互相ping
pc1自动获取到192.168.10.99,pc2获取到192.168.20.99
在华为交换机里面分配地址默认从最大数开始分配(这里99,是因为配置了100-253不给分配),思科交换机默认是是从最小数开始分配。
华为交换机配置DHCP_第9张图片
华为交换机配置DHCP_第10张图片

基于全局DHCP配置

全局开启DHCP
创建VLAN10、20
VLAN分配IP并指定DHCP模式
端口分入相应VLAN
创建地址池10、20
指定各自的网关、dns、租期、不给分配地址

<Huawei>system-view
Enter system view, return user view with Ctrl+Z.
[Huawei]undo info-center enable
Info: Information center is disabled.
[Huawei]dhcp enable
Info: The operation may take a few seconds. Please wait for a moment.done.
[Huawei]vlan batch 10 20
Info: This operation may take a few seconds. Please wait for a moment...done.
[Huawei]interface vlanif 10
[Huawei-Vlanif10]ip address 192.168.10.254 24
[Huawei-Vlanif10]dhcp select glo	
[Huawei-Vlanif10]dhcp select global 
[Huawei-Vlanif10]q
[Huawei]interface vlanif 20
[Huawei-Vlanif20]ip address 192.168.20.254 24
[Huawei-Vlanif20]dhcp select global
[Huawei-Vlanif20]q
[Huawei]interface gigabitethernet 0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type access
[Huawei-GigabitEthernet0/0/1]port default vlan 10
[Huawei-GigabitEthernet0/0/1]interface gigabitethernet 0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 20
[Huawei-GigabitEthernet0/0/2]q
[Huawei]ip pool 10
Info:It's successful to create an IP address pool.
[Huawei-ip-pool-10]network 192.168.10.0 mask 24
[Huawei-ip-pool-10]gateway-list 192.168.10.254
[Huawei-ip-pool-10]dns-list 1.1.1.1
[Huawei-ip-pool-10]lease day 1
[Huawei-ip-pool-10]q
[Huawei]ip pool 20
Info:It's successful to create an IP address pool.
[Huawei-ip-pool-20]network 192.168.20.0 mask 24
[Huawei-ip-pool-20]gateway-list 192.168.20.254
[Huawei-ip-pool-20]dns-list 2.2.2.2
[Huawei-ip-pool-20]lease day 2
[Huawei-ip-pool-20]excluded-ip-address 192.168.20.201 192.168.20.253
[Huawei-ip-pool-20]q
[Huawei]

pc1、2开启自动获取,相互ping
pc1分配到192.168.10.253地址
pc2分配到192.168.20.200(配置排除了分配20.201-20.253地址)
华为交换机配置DHCP_第11张图片
华为交换机配置DHCP_第12张图片

你可能感兴趣的:(运维,华为,网络)