华为路由器开启DHCP
来源:原创
时间:2024-03-13
作者:脚本小站
分类:网络
R1:
<Huawei>system-view Enter system view, return user view with Ctrl+Z. [Huawei]un in en [Huawei]sysname R1 [R1]dhcp enable [R1]ip pool 1 # 创建地址池 [R1-ip-pool-1]network 192.168.1.0 mask 24 # 设置网段 [R1-ip-pool-1]gateway-list 192.168.1.1 # 网关地址 [R1-ip-pool-1]int g0/0/0 [R1-GigabitEthernet0/0/0]ip add [R1-GigabitEthernet0/0/0]ip address 192.168.1.1 24 # 为这个口设置网关 [R1-GigabitEthernet0/0/0]dhcp select global # 选择全局地址池,这里不用选地址池,因为会根据网关地址来选择地址池 # 配置192.168.2.0/24网段的地址池 [R1]ip pool 2 [R1-ip-pool-2]network 192.168.2.0 mask 24 [R1-ip-pool-2]gateway-list 192.168.2.1 [R1-ip-pool-2]excluded-ip-address 192.168.2.100 192.168.2.253 # 排除这些地址 [R1-ip-pool-2]int e0/0/1 [R1-Ethernet0/0/1]int e0/0/0 [R1-Ethernet0/0/0] [R1-Ethernet0/0/0]ip address 192.168.2.1 24 [R1-Ethernet0/0/0]dhcp select global
在PC上执行ipconfig可获取到ip地址。