当前位置:网站首页>DHCP服务
DHCP服务
2022-07-28 05:28:00 【花生味花生米】
前言
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,使用UDP协议工作, 主要有两个用途:给内部网络或网络服务供应商自动分配IP地址,给用户或者内部网络管理员作为对所有计算机作中央管理的手段。
一.什么是DHCP
DHCP(动态分配IP地址)
由internet工作小组设计开发
专门用于为TCP/IP网络中的计算机自动分配IP地址
二.DHCP的好处
减少管理员的工作量
避免输入错误的可能
避免IP地址冲突
当网络更改IP地址段时,不需要再重新配置每个用户的IP地址
提高了IP 地址的利用率
方便客户端的配置
三.DHCP的分配方式
自动分配:分配到一个IP地址后永久使用(可直接做静态)
手动分配:由DHCP服务器管理员专门指定IP地址
动态分配:使用完后释放该IP地址,供其他客户及使用
四.DHCP的租约过程
客户及从DHCP服务器获得IP地址的过程为DHCP租约工程
discover 1.客户机以广播方式发送discover向服务器请求IP地址
offer 2.服务器收到discover报文,会找一个ip,加上相应的租约期(网关、dns服务器)
组成一个offer报文,发给客户端,告知客户端可以提供IP地址
resquest 3.客户端会收到很多offer报文,选择一个应答报文作为自己的目标服务器,向服务
器发送resquest请求报文
ack 4.服务器收到resquest亲求报文,根据报文确认发送ack给客户端
更新租约
当DHCP服务器向客户机出租的IP地址租期达到50%时,就需要更新租约
客户机直接向提供租约的服务器发送DHCPrequest包,要求更新现有的地址租约
五.为什么使用DHCP
DHCP服务避免因手动设置ip地址照成冲突或错误,DHCP提供了安全,可靠且简单的TCP/IP网络设置,降低了配置IP地址的负载。
典型c/s模式
在网络中架设一台专用的DHCP服务器,负责集中分配各种地址参数(主要包括IP地址、子网掩码、网关、广播地址、dns服务器地址),其他主机于DHCP服务器进行通信,即可获取IP地址
服务端运行DHCP服务监听67端口
客户端运行DHCP程序监听68端口
六.DHCP配置

1.配置步骤


2.网络配置
sw1配置
<Huawei>undo t m
<Huawei>system-view
[Huawei]vlan batch 10 20 100
[Huawei]int e0/0/1
[Huawei-Ethernet0/0/1]port link-type access
[Huawei-Ethernet0/0/1]port default vlan 10
[Huawei-Ethernet0/0/1]int e0/0/2
[Huawei-Ethernet0/0/2]port link-type access
[Huawei-Ethernet0/0/2]port default vlan 20
[Huawei-Ethernet0/0/2]int e0/0/3
[Huawei-Ethernet0/0/3]port link-type access
[Huawei-Ethernet0/0/3]port default vlan 100
[Huawei-Ethernet0/0/3]int e0/0/5
[Huawei-Ethernet0/0/5]port link-type access
[Huawei-Ethernet0/0/5]port default vlan 100
[Huawei-Ethernet0/0/5]int e0/0/4
[Huawei-Ethernet0/0/4]port link-type trunk
[Huawei-Ethernet0/0/4]port trunk allow-pass vlan all
sw2配置
<Huawei>undo t m
<Huawei>system-view
[Huawei]vlan batch 10 20 100
[Huawei]int vlan 10
[Huawei-Vlanif10]ip add 192.168.1.1 24
[Huawei-Vlanif10]int vlan 20
[Huawei-Vlanif20]ip add 192.168.2.1 24
[Huawei-Vlanif20]int vlan 100
[Huawei-Vlanif100]ip add 192.168.31.2 24
[Huawei-Vlanif100]int g0/0/1
[Huawei-GigabitEthernet0/0/1]port link-type trunk
[Huawei-GigabitEthernet0/0/1]port trunk allow-pass vlan all
[Huawei-GigabitEthernet0/0/1]q
[Huawei]dhcp enable
[Huawei]int vlan 10
[Huawei-Vlanif10]dhcp select relay
[Huawei-Vlanif10]dhcp relay server-ip 192.168.31.10
[Huawei-Vlanif10]int vlan 20
[Huawei-Vlanif20]dhcp select relay
[Huawei-Vlanif20]dhcp relay server-ip 192.168.31.10
[Huawei-Vlanif20]int vlan 100
[Huawei-Vlanif100]dhcp select relay
[Huawei-Vlanif100]dhcp relay server-ip 192.168.31.10



边栏推荐
- MySQL master-slave
- Test interview questions collection (III) | computer network and database (with answers)
- Repair the faulty sector
- Use powercli to create a custom esxi ISO image
- Which is the best and most cost-effective air conduction headset recommended
- Hdu-1097-a hard puzzle (fast power)
- Clock tree analysis example
- DHCP principle and configuration
- Ubuntu18.04+centos7 configure redis master-slave [learning notes]
- Shell script - sort, uniq, TR, array sort, cut, Eval command configuration
猜你喜欢

MOOC翁恺C语言第八周:指针与字符串:1.指针2.字符类型3.字符串4.字符串计算

iptables防火墙

Principle and configuration of NAT and pat

Custom component -- pure data field & component life cycle

Technology sharing | interface testing value and system

MOOC翁恺C语言 第四周:进一步的判断与循环:3.多路分支4.循环的例子5.判断和循环常见的错误

VMware Workstation 配置net模式

SSH服务配置

Technology sharing | common proxy tools for interface testing

Repair the faulty sector
随机推荐
小甲鱼C(第六章数组1、2)
KVM hot migration
How about air conduction Bluetooth headset? It's the most worthwhile air conduction headset to start with
Shell script - regular expression
Firewall - iptables firewall (four tables and five links, firewall configuration method, detailed explanation of matching rules)
shell脚本——“三剑客”之awk命令
DHCP原理与配置
What is a linear table?
shell脚本——正则表达式
It is recommended to wear air conduction earphones, which do not need to wear in ear
Software testing (concept)
Applet creation component
Suger Bi create task
Hdu-5783 divide the sequence (greedy water question)
Network - data link layer
技术分享 | 接口测试常用代理工具
[learning notes] thread creation
HDU-5806-NanoApeLovesSequenceⅡ(尺取法)
QT使用MSVC编译器输出中文乱码问题
Shell script -- program conditional statements (conditional tests, if statements, case branch statements, echo usage, for loops, while loops)