当前位置:网站首页>DHCP服务详解
DHCP服务详解
2022-08-04 01:44:00 【小猴子_xiao】
DHCP服务
了解DHCP服务的工作原理
能够配置简单的dhcp服务器
一、DHCP服务介绍
DHCP(Dynamic Host Configuration Protocol,动态主机配置协议)是一个局域网的网络协议,UDP协议,67号端口
主要用于动态管理分配IP地址
二、DHCP服务的工作原理
过程分析:
dhcpdiscover(发现):该过程中客户端开始建立请求
dhcpoffer(提供):当网络中的dhcp服务器收到dhcpdiscover信息后,对自身进行检查。
dhcprequset(请求):当dhcp客户收到服务器的返回信息后,就以广播的方式发送
dhcpack(确认):一旦被选中的dhcp收到客户端的请求信息后,就将以保留的这个ip标识为以租用
三、DHCP服务器配置
环境准备:云服务器,我用的是3A网络的,上手简单,适合小白,可以随时更换ip地址。
步骤:
安装dhcp软件包
[[email protected] ~]# yum -y install dhcp [[email protected] ~]# rpm -ql dhcp /etc/dhcp /etc/dhcp/dhcpd.conf //主配置文件
修改配置文件
vim /etc/dhcp/dhcpd.conf option domain-name "itcast.cc"; //域名 option domain-name-servers 192.168.1.110, 8.8.8.8; //DNS(可以写多个) default-lease-time 3600; //缺省租约 max-lease-time 7200; //客户端最大租约 log-facility local7; //定义日志设备载体 (/var/log/boot.log输出)
subnet 10.1.1.0 netmask 255.255.255.0 { range 10.1.1.100 10.1.1.150; option routers 10.1.1.1; option broadcast-address 10.1.1.255 } [[email protected] ~]# service dhcpd start Starting dhcpd: [FAILED] //启动失败 原因分析: 当我们排除了所有可能的情况下还找不出原因的话,就需要通过日志去分析
日志错误信息
[[email protected] ~]# tail -f /var/log/messages Apr 16 17:54:22 MissHou dhcpd: /etc/dhcp/dhcpd.conf line 16: semicolon expected. Apr 16 17:54:22 MissHou dhcpd: } Apr 16 17:54:22 MissHou dhcpd: ^ Apr 16 17:54:22 MissHou dhcpd: /etc/dhcp/dhcpd.conf line 16: unexpected end of file Apr 16 17:54:22 MissHou dhcpd: } Apr 16 17:54:22 MissHou dhcpd: ^ Apr 16 17:54:22 MissHou dhcpd: Configuration file errors encountered -- exiting Apr 16 17:54:22 MissHou dhcpd: 通过查看日志发现,在}附近有报错,再次查看配置文件,发现少了一个分号; 更改如下: option domain-name "itcast.cc"; option domain-name-servers 8.8.8.8; default-lease-time 3600; max-lease-time 7200; log-facility local7;
测试验证
client端修改IP地址为动态获取: [[email protected] ~]# vim /etc/sysconfig/network-scripts/ifcfg-eth0 [[email protected] ~]# cat /etc/sysconfig/network-scripts/ifcfg-eth0 DEVICE=eth0 TYPE=Ethernet ONBOOT=yes NM_CONTROLLED=yes BOOTPROTO=dhcp 重启网络让client端自动获取IP地址: [[email protected] ~]# service network restart Shutting down loopback interface: [ OK ] Bringing up loopback interface: [ OK ] Bringing up interface eth0: Active connection state: activating Active connection path: /org/freedesktop/NetworkManager/ActiveConnection/
边栏推荐
- Kubernetes:(十一)KubeSphere的介绍和安装(华丽的篇章)
- C语言力扣第54题之螺旋矩阵。模拟旋转
- 持续投入商品研发,叮咚买菜赢在了供应链投入上
- nodejs安装及环境配置
- How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
- 静态文件快速建站
- Slipper - virtual point, shortest path
- Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
- 【正则表达式】笔记
- 简单排序(暑假每日一题 14)
猜你喜欢
随机推荐
GNSS【0】- 专题
initramfs详解----添加硬盘驱动并访问磁盘
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
How to copy baby from Taobao (or Tmall store) through API interface to Pinduoduo interface code docking tutorial
GNSS文章汇总
Android interview questions and answer analysis of major factories in the first half of 2022 (continuously updated...)
Continuing to invest in product research and development, Dingdong Maicai wins in supply chain investment
Kubernetes:(十一)KubeSphere的介绍和安装(华丽的篇章)
The idea of the diagram
第13章 网络安全漏洞防护技术原理与应用
《Greenplum构建实时数据仓库实践》简介
VR panorama shooting online exhibition hall, 3D panorama brings you an immersive experience
网页三维虚拟展厅为接入元宇宙平台做基础
HBuilderX的下载安装和创建/运行项目
企业虚拟偶像产生了实质性的价值效益
Simple sorting (summer vacation daily question 14)
MySQL回表指的是什么
天地图坐标系转高德坐标系 WGS84转GCJ02
Use of lombok annotation @RequiredArgsConstructor
【无标题】