DHCP命令合集DHCP全局地址池Sysnamesystem-view[Sysname]dhcpenable使能DHCP服务[Sysname]dhcpserverip-pool0创建标识为0的DHCP普通模式地址池[Sysname-dhcp-pool-0]network192.168.8.0mask255.255.255.0配置DHCP地址池0动态分配的地址范围为192.168.8.0/24[Sysname-dhcp-pool-0]gateway-list10.110.1.99配置DHCP地址池0为DHCP客户端分配的网关地址为10.110.1.99[Sysname-dhcp-pool-0]dns-list10.1.1.254配置DHCP地址池0为DHCP客户端分配的DNS服务器地址为10.1.1.254[Sysname-dhcp-pool-0]expiredday1hour2minute3配置地址池0的IP地址租用有效期为1天2小时3分。[Sysname-dhcp-pool-0]domain-namemydomain.com配置DHCP地址池0为DHCP客户端分配的域名后缀为mydomain.com[Sysname-dhcp-pool-0]netbios-typeb-node配置DHCP地址池0为DHCP客户端分配的NetBIOS节点类型为b-node[Sysname-dhcp-pool-0]nbns-list10.12.1.99配置DHCP地址池0为DHCP客户端分配WINS服务器地址为10.12.1.99[Sysname]dhcpserverforbidden-ip10.110.1.110.110.1.63将10.110.1.1到10.110.1.63之间的IP地址保留,不参与地址自动分配[Sysname-dhcp-pool-0]static-bindip-address10.1.1.1mask255.255.255.0[Sysname-dhcp-pool-0]static-bindmac-address0000-e03f-0305将MAC地址为0000-e03f-0305的PC机与IP地址10.1.1.1绑定,掩码为255.255.255.0[Sysname-Vlan-interface1]dhcpselectserverglobal-pool配置VLAN接口1工作在DHCP服务器模式[Sysname]dhcpserverdetect使能伪DHCP服务器检测功能DHCP全局地址池查看命令displaydhcpserverconflict显示DHCP的地址冲突统计信息displaydhcpserverexpired显示所有DHCP地址池中的租约超期信息displaydhcpserverfree-ip显示DHCP地址池的可用地址信息displaydhcpserverforbidden-ip显示DHCP地址池中不参与自动分配的IP地址displaydhcpserverip-in-use显示所有DHCP地址池的地址绑定信息displaydhcpserverstatistics显示DHCP服务器的统计信息displaydhcpservertree显示所有DHCP地址池的信息DHCP扩展地址池Sysnamesystem-view[Sysname]dhcpserverip-pool0extended配置扩展模式地址池0[Sysname-dhcp-pool-0]networkiprange192.168.8.1192.168.8.150动态分配的地址范围为192.168.8.1到192.168.8.150[Sysname-dhcp-pool-0]networkmask255.255.255.0配置扩展模式地址池0动态分配的IP地址掩码为255.255.255.0[Sysname-dhcp-pool-0]forbidden-ip192.168.1.3192.168.1.10配置DHCP扩展模式地址池0中不参与分配的IP地址为192.168.1.3和192.168.1.10其他比如网关比如DNS同上[Sysname-Vlan-interface1]dhcpserverapplyip-pool0配置VLAN接口1引用DHCP扩展模式地址池0必须要输入,否则在扩展DHCP模式下客户端获取不到IP!DHCP中继模式#配置DHCP服务器组1的服务器IP地址为1.1.1.1。Sysnamesystem-view[Sysname]dhcprelayserver-group1ip1.1.1.1#配置VLAN接口1与DHCP服务器组1的归属关系。Sysnamesystem-view[Sysname]interfacevlan-interface1[Sysname-Vlan-interface1]dhcprelayserver-select1#配置VLAN接口1工作在DHCP中继模式。Sysnamesystem-view[Sysname]interfacevlan-interface1[Sysname-Vlan-interface1]dhcpselectrelay#使能伪DHCP服务器检测功能。Sysnamesystem-view[Sysname]dhcprelayserver-detectDHCP中继模式查看命令displaydhcprelay显示所有接口对应的DHCP服务器组的信息displaydhcprelayinformation显示DHCP中继上Option82的配置信息displaydhcprelaysecurity显示DHCP中继的用户地址表项信息displaydhcprelaysecuritystatistics显示DHCP中继用户地址表项的统计信息displaydhcprelaysecuritytracker显示DHCP中继动态用户地址表项的定时刷新周期displaydhcprelayserver-group显示DHCP服务器组中服务器的IP地址displaydhcprelaystatistics显示所有DHCP服务器组的相关报文统计信息之和resetdhcprelaystatistics清除所有DHCP服务器组的DHCP中继的统计信息DHCP客服端#指定VLAN接口1使用DHCP方式获取IP地址。Sysnamesystem-view[Sysname]interfacevlan-interface1[Sysname-Vlan-interface1]ipaddressdhcp-allocSysnamedisplaydhcpclient显示所有接口的DHCP客户端相关信息DHCPSnooping[Sysname]dhcp-snooping使能DHCPSnooping功能Sysnamesystem-view[Sysname]interfaceGigabitEthernet1/0/1[Sysname-GigabitEthernet1/0/1]dhcp-snoopingtrust配置以太网端口GigabitEthernet1/0/1为信任端口,并记录客户端IP地址和MAC地址的绑定关系DHCPSnooping查看命令displaydhcp-snooping显示DHCPSnooping表项信息displaydhcp-snoopinginformation显示所有接口对应的Option82配置信息displaydhcp-snoopingpacketstatistics显示DHCPSnooping设备上的DHCP报文统计信息displaydhcp-snoopingtrust显示信任端口信息resetdhcp-snooping清除所有的DHCPSnooping表项resetdhcp-snoopingpacketstatistics清除DHCPSnooping设备上的DHCP报文统计信息