思科设备参考:DHCP自动获取IP地址实验(思科)
一,实验目的
路由器搭载DHCP,让PC通过DHCP自动获取IP地址
二,不划分vlan--全局地址池
实验拓扑
配置命令
Router
<Huawei>system-view
[Huawei]ip pool mypool
[Huawei-ip-pool-mypool]network 192.168.10.0
[Huawei-ip-pool-mypool]excluded-ip-address 192.168.10.10 192.168.10.254
[Huawei-ip-pool-mypool]lease day 2 hour 0 minute 0
[Huawei-ip-pool-mypool]dns-list 114.114.114.114
[Huawei-ip-pool-mypool]quit
[Huawei]dhcp enable
[Huawei]int g0/0/0
[Huawei-GigabitEthernet0/0/0]ip address 192.168.10.254 24
[Huawei-GigabitEthernet0/0/0]dhcp select global
[Huawei-GigabitEthernet0/0/0]quit
[Huawei]display current-configuration
测试结果
PC1 和 PC2 成功获取到 IP 地址
① 打开PC--->基础配置--->IPv4配置--->DHCP--->应用
② 命令行--->输入指令 ipconfig /renew
三,划分vlan--接口地址池
实验拓扑
配置命令
Switch
<Huawei>sys
<Huawei>system-view
[Huawei]vlan batch 10 20
[Huawei]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[Huawei-GigabitEthernet0/0/1]quit
[Huawei]int g0/0/2
[Huawei-GigabitEthernet0/0/2]port link-type access
[Huawei-GigabitEthernet0/0/2]port default vlan 10
[Huawei-GigabitEthernet0/0/2]quit
[Huawei]int g0/0/3
[Huawei-GigabitEthernet0/0/3]port link-type access
[Huawei-GigabitEthernet0/0/3]port default vlan 10
[Huawei-GigabitEthernet0/0/3]quit
[Huawei]int g0/0/4
[Huawei-GigabitEthernet0/0/4]port link-type access
[Huawei-GigabitEthernet0/0/4]port default vlan 20
[Huawei-GigabitEthernet0/0/4]quit
[Huawei]int g0/0/5
[Huawei-GigabitEthernet0/0/5]port link-type access
[Huawei-GigabitEthernet0/0/5]port default vlan 20
[Huawei-GigabitEthernet0/0/5]quit
[Huawei]display current-configuration
Router
<Huawei>system-view
[Huawei]dhcp enable
[Huawei]int g0/0/0.10
[Huawei-GigabitEthernet0/0/0.10]dot1q termination vid 10
[Huawei-GigabitEthernet0/0/0.10]ip address 192.168.10.1 24
[Huawei-GigabitEthernet0/0/0.10]arp broadcast enable
[Huawei-GigabitEthernet0/0/0.10]dhcp select interface
[Huawei-GigabitEthernet0/0/0.10]dhcp server dns-list 8.8.8.8
[Huawei-GigabitEthernet0/0/0.10]dhcp server domain-name vl_10
[Huawei-GigabitEthernet0/0/0.10]dhcp server lease day 3 hour 3 minute 3
[Huawei-GigabitEthernet0/0/0.10]dhcp server excluded-ip-address 192.168.10.5 192.168.10.254
[Huawei-GigabitEthernet0/0/0.10]quit
[Huawei]int g0/0/0.20
[Huawei-GigabitEthernet0/0/0.20]dot1q termination vid 20
[Huawei-GigabitEthernet0/0/0.20]ip address 192.168.20.1 24
[Huawei-GigabitEthernet0/0/0.20]arp broadcast enable
[Huawei-GigabitEthernet0/0/0.20]dhcp select interface
[Huawei-GigabitEthernet0/0/0.20]dhcp server dns-list 8.8.8.8
[Huawei-GigabitEthernet0/0/0.20]dhcp server domain-name vl_20
[Huawei-GigabitEthernet0/0/0.20]dhcp server lease day 3 hour 3 minute 3
[Huawei-GigabitEthernet0/0/0.20]dhcp server excluded-ip-address 192.168.20.5 192.168.20.254
[Huawei-GigabitEthernet0/0/0.20]quit
[Huawei]display current-configuration
测试结果
四台 PC 都能成功获取到 IP 地址