[神州数码]DHCP的配置

DHCP的配置


DHCP(Dynamic Host Configuration Protocol,动态主机配置协议),前身是BOOTP协议,是一个局域网的网络协议,使用UDP协议工作,统一使用两个IANA分配的端口:67(服务器端),68(客户端)。DHCP通常被用于局域网环境,主要作用是集中的管理、分配IP地址,使client动态的获得IP地址、Gateway地址、DNS服务器地址等信息,并能够提升地址的使用率。简单来说,DHCP就是一个不需要账号密码登录的、自动给内网机器分配IP地址等信息的协议。

service dhcp //开启IPv4DHCP功能

Ipv6 enable //开启ipv6
ip dhcp pool <地址池名称> //创建IPv4地址池

ipv6 dhcp pool <地址池名称> //创建IPv6地址池
network <网络地址> <子网掩码> //设置分配的网段和子网掩码
default-router <默认网关> //配置默认网关
dns-server <DNS1> <DNS2> //配置DNS服务器
ip dhcp excluded-address <ip地址> //设置保留地址
ip forward-protocol udp bootps //开启DHCP中继
    switch(config-if)#ip helper-address <ip> //配置VLAN中继

例题:

SW2配置DHCPv4和DHCPv6,地址池名称:VALN10,VLAN20,并为SW1开启DHCP中继

地址池名称ip默认网关DNS1
VLAN1010.114.10.0/2410.114.10.2548.8.8.8
VLAN2010.114.20.0/2410.114.20.2548.8.8.8
VLAN10v62001:1:10:02001:1:10:18.8.8.8

保留地址:

10.114.10.25410.114.10.58
10.114.20.25410.114.10.3
SW2:
switch(config)#service dhcp
switch(config)#ip dhcp pool VLAN10
switch(dhcp-config)#network 10.114.10.0 255.255.255.0
switch(dhcp-config)#default-router 10.114.10.254
switch(dhcp-config)#dns-server 8.8.8.8
switch(dhcp-config)#exit
switch(config)#ip dhcp pool VLAN20
switch(dhcp-config)#network 10.114.20.254
switch(dhcp-config)#default-router 10.114.20.254
switch(dhcp-config)#dns-server 8.8.8.8
switch(dhcp-config)#exit
switch(config)#ipv6 enable
switch(config)#ipv6 dhcp pool VLAN10v6
switch(dhcp-config)#network 2001:1:10:0 64
switch(dhcp-config)#default-router 2001:1:10:1
switch(dhcp-config)#dns-server 8.8.8.8
switch(config)#ip dhcp excluded-address 10.114.10.254
switch(config)#ip dhcp excluded-address 10.114.10.58
switch(config)#ip dhcp excluded-address 10.114.20.254
switch(config)#ip dhcp excluded-address 10.114.20.3
switch(config)#exit
SW1:
switch(config)#service dhcp
switch(config)#service dhcpv6
switch(config)#ip forward-protocol udp bootps 
switch(config)#int vlan 10
switch(config-if)#ip helper-address 10.1.1.1 (10.1.1.1是SW1-SW2的接口地址)
评论区
头像