当前位置:网站首页>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



边栏推荐
- Principle and configuration of NAT and pat
- Traversal binary tree
- HDU-1097-A hard puzzle(快速幂)
- Cocos2d-x learning notes Tile Map tiledmap
- Compilation and preprocessing of C language
- Esxi community network card driver updated again
- Shell script -- program conditional statements (conditional tests, if statements, case branch statements, echo usage, for loops, while loops)
- Create, traverse and search nodes as required for single linked list
- What is the most practical gift for Tanabata? A gift that will never go wrong is worth buying
- Technology sharing | how to simulate real use scenarios? Mock technology to help you
猜你喜欢

What's a good gift for Tanabata? Niche and advanced product gift recommendation

Firewall - iptables firewall (four tables and five links, firewall configuration method, detailed explanation of matching rules)

Servlet

iptables防火墙

Esxi community nvme driver update v1.1

QGraphicsView提升为QChartView

Custom components -- styles

FTP service

LNMP搭建过程详解

KVM热迁移
随机推荐
[learning notes] drive
Wechat applet custom compilation mode
Esxi community nvme driver update v1.1
测试人生 | 二线城市年薪超40W?疫情之下涨薪100% + 是怎么做到的?
shell脚本——正则表达式
Hdu-5806-nanoapelovesequence Ⅱ (ruler method)
Applet custom components - data, methods, and properties
Technology sharing | interface testing value and system
Custom component -- pure data field & component life cycle
Applet creation component
Icc2 analysis timing artifact analyze_ design_ violations
Teach you three steps to complete the construction of the test monitoring system hand in hand
What's a good gift for Tanabata? Niche and advanced product gift recommendation
MySQL master-slave
HDU-1097-A hard puzzle(快速幂)
Technology sharing | common proxy tools for interface testing
Which brand of air conduction earphones is better? These four should not be missed
Hdu-5805-nanoape loves sequence (thinking questions)
Test interview questions collection (V) | automated testing and performance testing (with answers)
[learning notes] VIM editor