如图所示,S1作为DHCP Server使用,同时充当默认网关,PC通过DHCP动态获取IP地址 接入网络。
S1全局下需要配置:IP Pool,DHCP Pool,DHCP Policy,打开DHCP功能开关。 S1接口下需要配置:IP地址,绑定DHCP Policy,DHCP Server模式。
配置思路
1.配置IP Pool,IP Pool配置的是地址池范围等相关选项,地址池的范围要限制在一个 网段内。
2.配置DHCP Pool,DHCP Pool需要绑定一个IP Pool,管理DNS、lease-time、default router等设置。
3.配置DHCP Policy,DHCP Policy是策略选项,同一个名字下支持多个优先级别,用于 策略管理。
4.配置DHCP Server,在DHCP接口模式下配置为Server功能模式,并绑定刚配置的Policy 。
5.配置全局使能DHCP。
在S1上的配置如下:
/*配置IP POOL*/
S1(config)#ip pool pool1
S1(config-ip-pool)#range 10.10.1.3 10.10.1.254 255.255.255.0
S1(config-ip-pool)#exit
/*把IP POOL和DHCP POOL绑定*/
S1(config)#ip dhcp pool pool1
S1(config-dhcp-pool)#ip-pool pool1
S1(config-dhcp-pool)#exit
/*把DHCP POOL和DHCP POLICY绑定*/
S1(config)#ip dhcp policy policy1 1
S1(config-dhcp-policy)#dhcp-pool pool1
S1(config-dhcp-policy)#exit
/*配置接口和接口的IP地址*/
S1(config)#switch vlan-configuration
S1(config-swvlan)#vlan1000
S1((config-swvlan-sub)#switchport pvid gei-0/1/1/1
S1((config-swvlan-sub)#exit
S1(config-swvlan)#exit
S1(config)#interface vlan1000
S1(config-if)#ip address 10.10.1.1 255.255.255.0
S1(config-if)#exit
/*使能DHCP*/
S1(config)#dhcp
S1(config-dhcp)#enable
/*接口下配置SERVER模式以及选定policy*/
S1(config-dhcp)#interface vlan1000
S1(config-dhcp-if)#mode server
S1(config-dhcp-if)#policy policy1
S1(config-dhcp-if)#exit
S1(config-dhcp)#exit
配置验证:
在S1上查看IP POOL的配置:
S1(config)#show ip local pool
PoolName Begin End Mask Free Used
pool1 10.10.1.3 10.10.1.254 24 252 0
TotalPool: 1
在S1上查看DHCP POOL的配置:
S1(config)#show ip dhcp pool
oolName IpPool LeaseTime DnsNum RouterNum OptionNum BindNum
pool1 pool1 0 1 0 0 0
在S1上查看DHCP POLICY的配置:
S1(config)#show ip dhcp pool
PoolName IpPool LeaseTime DnsNum RouterNum OptionNum BindNum
pool1 pool1 0 1 0 1 0 0 0
在S1上显示指定接口下的DHCP的配置:
S1(config)#show running-config-interface vlan1000
!<Interface>
interface vlan1000
ip address 10.10.1.1 255.255.255.0
$
!</Interface>
!<ETHER_PORT>
interface vlan1000
!</ETHER_PORT>
!</DHCP>
dhcp
interface vlan1000
mode server
policy 1000
$
$
!</DHCP>