ip dhcp excluded 192.168.0.1 (排除的IP) ip dhcp pool xxx(随便你定义的名字) network 192.168.0.0 255.255.255.0 (你分配的IP段) default-router 192.168.0.1 (关网的网内) dns-server 202.96.64.68 (DNS服务器的IP) lease 7 netbios-name-server Router>en Password: Router#conf t Enter configuration commands, one per line. End with CNTL/Z. Router(config)#ip dhcp excluded 10.10.0.1 10.10.0.254 Router(config)#ip dhcp pool office Router(dhcp-config)#network 10.10.0.0 255.255.255.0 Router(dhcp-config)#default-router 10.10.0.254 Router(dhcp-config)#dns-server 208.67.222.222 208.67.220.220 Router(dhcp-config)#netbios-name-server 10.10.0.2 Router(dhcp-config)#lease 7 Router(dhcp-config)#end Router#
可变长子网掩码实例
ip dhcp excluded-address 192.168.40.250 192.168.40.254 ip dhcp excluded-address 192.168.50.250 192.168.50.254 ! ip dhcp pool Office-1 network 192.168.40.240 255.255.255.240 default-router 192.168.40.254 dns-server 208.67.222.222 208.67.220.220 lease 7 ! ip dhcp pool Office-2 network 192.168.50.128 255.255.255.128 default-router 192.168.50.254 dns-server 208.67.222.222 208.67.220.220 lease 7 ! interface GigabitEthernet0/1 description Office-1 ip address 192.168.40.254 255.255.255.240 ip nat inside ip virtual-reassembly in duplex auto speed auto ! interface GigabitEthernet0/2 description Office-2 ip address 192.168.50.254 255.255.255.128 ip nat inside ip nat enable ip virtual-reassembly in duplex auto speed auto ! 2911(dhcp-config)#do show ip dhcp pool Office-2 Pool Office-2 : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 126 Leased addresses : 0 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.50.129 192.168.50.129 - 192.168.50.254 0 2911(config)#do show ip dhcp pool Office-1 Pool Office-1 : Utilization mark (high/low) : 100 / 0 Subnet size (first/next) : 0 / 0 Total addresses : 14 Leased addresses : 1 Pending event : none 1 subnet is currently in the pool : Current index IP address range Leased addresses 192.168.40.242 192.168.40.241 - 192.168.40.254 1