HCNA-44 配置DHCP
基于接口配置DHCP <Huawei>system-view [Huawei]sysnamer1 [r1]interfaceGigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]ipaddress 192.168.10.1 24 [r1-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [r1-GigabitEthernet0/0/1]ipaddress 192.168.20.1 24 [r1-GigabitEthernet0/0/1]quit [r1]dhcpenable //全局开启DHCP [r1-GigabitEthernet0/0/0]dhcpselect interface //配置DHCP基于接口Server [r1-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [r1-GigabitEthernet0/0/1]dhcpselect interface [r1]interfaceGigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]dhcpserver lease day 0 hour 12 minute 0 //配置DHCP租约 [r1-GigabitEthernet0/0/0]dhcpserver excluded-ip-address 192.168.10.200 192.168. 10.254 //配置DHCP地址池内不参与分配的地址(保留地址) [r1-GigabitEthernet0/0/0]dhcpserver dns-list 114.114.114.114 //配置DHCP的DNS服务地址 [r1]interfaceGigabitEthernet 0/0/1 [r1-GigabitEthernet0/0/1]dhcpserver excluded-ip-address 192.168.20.200 192.168. 20.254 [r1-GigabitEthernet0/0/1]dhcpserver lease day 0 hour 12 minute 0 [r1-GigabitEthernet0/0/1]dhcpserver dns-list 114.114.114.114 [r1-GigabitEthernet0/0/1]displaythis //查看配置 [V200R003C00] # interfaceGigabitEthernet0/0/1 ip address 192.168.20.1 255.255.255.0 dhcp select interface dhcp server excluded-ip-address 192.168.20.200192.168.20.254 dhcp server lease day 0 hour 12 minute 0 dhcp server dns-list 114.114.114.114 # Return [r1]displayip pool //查看IP地址池 ----------------------------------------------------------------------- Pool-name :GigabitEthernet0/0/0 Pool-No : 0 Position : Interface Status : Unlocked Gateway-0 : 192.168.10.1 Mask : 255.255.255.0 VPN instance : -- ----------------------------------------------------------------------- Pool-name :GigabitEthernet0/0/1 Pool-No : 1 Position : Interface Status : Unlocked Gateway-0 : 192.168.20.1 Mask : 255.255.255.0 VPN instance : -- IP address Statistic Total :506 Used :2 Idle :394 Expired :0 Conflict :0 Disable :110 PC>ipconfig Linklocal IPv6 address...........: fe80::5689:98ff:fe20:2080 IPv6address......................: :: / 128 IPv6gateway......................: :: IPv4address......................: 192.168.10.199 Subnetmask.......................: 255.255.255.0 Gateway...........................:192.168.10.1 Physicaladdress..................: 54-89-98-20-20-80 DNSserver........................: 114.114.114.114
基于全局配置DHCP <Huawei>system-view [Huawei]sysnamer1 [r1]interfaceGigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]ipaddress 192.168.10.1 24 [r1-GigabitEthernet0/0/0]interfaceGigabitEthernet 0/0/1 [r1-GigabitEthernet0/0/1]ipaddress 192.168.20.1 24 [r1-GigabitEthernet0/0/1]quit [r1]dhcpenable //全局DHCP服务开启 [r1]ippool zurkj //创建全局地址池 [r1-ip-pool-zurkj]network192.168.10.0 mask 255.255.255.0 //配置网段 掩码 [r1-ip-pool-zurkj]gateway192.168.10.1 //配置网关地址 [r1-ip-pool-zurkj]excluded-ip-address192.168.10.200 192.168.10.254 //配置DHCP地址池不参与地址(保留地址) [r1-ip-pool-zurkj]leaseday 0 hour 12 minute 0 //配置租约 [r1-ip-pool-zurkj]dns-list114.114.114.114 8.8.8.8 //配置主备DNS地址 [r1-ip-pool-zurkj]displaythis [r1-ip-pool-zurkj]quit [r1]ippool ipgzj [r1-ip-pool-ipgzj]network192.168.20.0 mask 24 [r1-ip-pool-ipgzj]gateway192.168.20.1 [r1-ip-pool-ipgzj]excluded-ip-address192.168.20.200 192.168.20.254 [r1-ip-pool-ipgzj]leaseday 0 hour 12 minute 0 [r1-ip-pool-ipgzj]dns-list114.114.114.114 8.8.8.8 [r1-ip-pool-ipgzj]quit [r1]interfaceGigabitEthernet 0/0/0 [r1-GigabitEthernet0/0/0]dhcpselect global //配置接口先择全局DHCP [r1]interfaceGigabitEthernet 0/0/1 [r1-GigabitEthernet0/0/1]dhcpselect global [r1-GigabitEthernet0/0/1]quit PC>ipconfig Linklocal IPv6 address...........: fe80::5689:98ff:fe20:2080 IPv6address......................: :: / 128 IPv6gateway......................: :: IPv4address......................: 192.168.10.199 Subnetmask.......................: 255.255.255.0 Gateway...........................:192.168.10.1 Physicaladdress..................: 54-89-98-20-20-80 DNSserver........................: 114.114.114.114 8.8.8.8 PC>ping192.168.20.199 Ping192.168.20.199: 32 data bytes, Press Ctrl_C to break From192.168.20.199: bytes=32 seq=1 ttl=127 time=79 ms From192.168.20.199: bytes=32 seq=2 ttl=127 time=93 ms From192.168.20.199: bytes=32 seq=3 ttl=127 time=94 ms From192.168.20.199: bytes=32 seq=4 ttl=127 time=47 ms From192.168.20.199: bytes=32 seq=5 ttl=127 time=62 ms ---192.168.20.199 ping statistics --- 5 packet(s) transmitted 5 packet(s) received 0.00% packet loss round-trip min/avg/max = 47/75/94 ms |