当前位置:网站首页>DHCP review
DHCP review
2022-06-25 23:59:00 【XUPT-BDAL-LAB-ML&OP】
(centos7)
brief introduction
Dynamic Host Configuration Protocol (DHCP) It's a kind of be based on UDP agreement And only in LAN Network protocol used internally , It is mainly used in large LAN environment or LAN environment with many mobile office devices , The purpose is to automatically allocate data for equipment or network suppliers within the LAN IP Address and other parameters , Provides information about network configuration “ Family bucket ” service .
dhcpd yes Linux Used in the system to provide DHCP The service procedure of . The package name is dhcp-server


DHCP Common terms involved
- Scope : A complete IP Address segment ,DHCP Manage the distribution of the network according to the scope 、IP Address assignment and other configuration parameters .
- Superscope : Used to manage multiple logical subnet segments in the same physical network , It contains a list of scopes that can be managed uniformly .
- Exclusion range : Put some... In scope IP Address exclusion , Make sure these IP The address will not be assigned to DHCP client .
- Address pool : Is defined. DHCP After the exclusion scope is applied , The rest is used to dynamically allocate to the client IP Address range .
- lease :DHCP The client can use dynamically allocated IP Time of address .
- make an appointment : Ensure that specific devices in the network always get the same IP Address .
working principle
One . Four steps to lease

2.1 DHCP Client to IP request

2.2 DHCP Server responds to requests

2.3 DHCP Client selection IP

2.4 DHCP Server confirms lease

Two . Renewal

/etc/dhcp/dhcpd.conf
#
# DHCP Server Configuration file.
# see /usr/share/doc/dhcp-server/dhcpd.conf.example
# see dhcpd.conf(5) man page
#
dhcpd Common parameters and functions used in the service program configuration file
Parameters effect
ddns-update-style type Definition DNS The type of service dynamic update , Types include :
none( Dynamic update not supported )、interim( Interactive update mode ) And ad-hoc( Special update mode )
allow/ignore client-updates allow / Ignore client updates DNS Record
default-lease-time 21600 Default timeout
max-lease-time 43200 Maximum timeout
option domain-name-servers 8.8.8.8 Definition DNS Server address
option domain-name "domain.org" Definition DNS domain name
range Define the IP Address pool
option subnet-mask Define the subnet mask for the client
option routers Define the gateway address of the client
broadcast-address Broadcast address Define the broadcast address of the client
ntp-server IP Address Define the client's network time server (NTP)
nis-servers IP Address Define client's NIS Address of domain server
hardware Hardware type MAC Address Specify the type of network card interface and MAC Address
server-name Host name towards DHCP Client notification DHCP The hostname of the server
fixed-address IP Address To fix something IP Address assigned to the specified host
time-offset Offset difference Specifies the offset difference between the client and Greenwich mean time
[[email protected] ~]# vim /etc/dhcp/dhcpd.conf
ddns-update-style none; Set up DNS The service does not automatically update dynamically
ignore client-updates; Ignore client updates DNS Record
subnet 192.168.10.0 netmask 255.255.255.0 {
The scope is 192.168.10.0/24 Network segment
range 192.168.10.50 192.168.10.150; IP The address pool is 192.168.10.50-150( about 100 individual IP Address )
option subnet-mask 255.255.255.0; Define the client's default subnet mask
option routers 192.168.10.1; Define the gateway address of the client
option domain-name "linuxprobe.com"; Define default search fields
option domain-name-servers 192.168.10.1; Define client's DNS Address
default-lease-time 21600; Define the default lease time ( Company : second )
max-lease-time 43200; Define the maximum appointment time ( Company : second )
}
firewall-cmd --zone=public --permanent --add-service=dhcp
firewall-cmd --reload
experiment
1. Basic experiments
server
yum install -y dhcp
vim /etc/dhcp/dhcpd.conf
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.50 192.168.10.150;
option subnet-mask 255.255.255.0;
# option routers 192.168.10.1;
# option domain-name "linuxprobe.com";
# option domain-name-servers 192.168.10.1;
default-lease-time 21600;
max-lease-time 43200;
service dhcpd restart
tail /var/log/message
Jun 20 07:20:11 localhost systemd: Started DHCPv4 Server Daemon.
Jun 20 07:20:13 localhost dhcpd: DHCPDISCOVER from 00:0c:29:d9:5e:93 via ens33
Jun 20 07:20:14 localhost dhcpd: DHCPOFFER on 192.168.10.50 to 00:0c:29:d9:5e:93 via ens33
Jun 20 07:20:14 localhost dhcpd: DHCPREQUEST for 192.168.10.50 (192.168.10.10) from 00:0c:29:d9:5e:93 via ens33
Jun 20 07:20:14 localhost dhcpd: DHCPACK on 192.168.10.50 to 00:0c:29:d9:5e:93 via ens33
2. Fixed address assignment
client
arp -a # obtain mac
server
host test {
hardware ethernet 00:0c:29:e3:2d:08
fixed-address 192.168.10.160
}
3. Superscope
Can solve ip Not enough address , One arm router
server
cp -a /etc/sysconfig/network-scripts/ifcfg-ens33 /etc/sysconfig/network-scripts/ifcfg-ens33:1
Change devcive,ipaddr
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p
cp -a /usr/share/doc/dhcp-4.2.5/dhcpd.conf.example /etc/dhcp/dhcpd.conf
vim /etc/dhcp/dhcpd.conf
:1,88d
shared-network 10-20 {
subnet 192.168.10.0 netmask 255.255.255.0 {
option routers 192.168.10.10;
range 192.168.10.200 192.168.10.200;
}
subnet 192.168.20.0 netmask 255.255.255.0 {
option routers 192.168.20.10;
range 192.168.20.100 192.168.20.200;
}
}
4. dhcp Relay server


dhcp The server vm10 192.168.10.10
vim /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR=192.168.10.10
NETMASK=255.255.255.0
DNS1=8.8.8.8
GATEWAY=192.168.10.20
service network restart
yum install dhcp -y
vim /etc/dhcp/dhcpd.conf
subnet 192.168.10.0 netmask 255.255.255.0 {
range 192.168.10.100 192.168.10.110;
option routers 192.168.10.20;
}
subnet 100.100.100.0 netmask 255.255.255.0 {
range 100.100.100.100 100.100.100.110;
option routers 100.100.100.20;
}
dhcp relay vm10 192.168.10.20 vm11 100.100.100.20
vim /etc/sysconfig/network-scripts/ifcfg-ens33
IPADDR=192.168.10.20
NETMASK=255.255.255.0
DNS1=8.8.8.8
GATEWAY=192.168.10.20
vim /etc/sysconfig/network-scripts/ifcfg-ens34
IPADDR=100.100.100.10
NETMASK=255.255.255.0
DNS1=8.8.8.8
GATEWAY=100.100.100.20
service network restart
yum install dhcp -y
cp /lib/systemd/system/dhcrelay.service /etc/systemd/system # take dhcp Relay master configuration file replication
vim /etc/systemd/system/dhcrelay.service # edit dhcp Relay master configuration file
[Service]
Type=notify
ExecStart=/usr/sbin/dhcrelay -d --no-pid -i ens33 -i ens35 192.168.10.10
vim /etc/sysctl.conf
net.ipv4.ip_forward = 1
sysctl -p
topic
https://www.linuxprobe.com/basic-learning-14.html
边栏推荐
- Keil compilation run error, missing error: # 5: # includecore_ cm3.h_ Old bear passing by_ Sina blog
- 请问可以不部署服务端实现图片上传吗?
- Jenkins 发布PHP项目代码
- 网络协议之:redis protocol详解
- 7.常用指令(下)v-on,v-bind,v-model的常见操作
- Lazy people teach you to use kiwi fruit to lose 16 kg in a month_ Old bear passing by_ Sina blog
- php进程间传递文件描述符
- 记录一些cf的题
- 用frp搭建云电脑
- SSL/TLS、对称加密和非对称加密和TLSv1.3
猜你喜欢

如何进行流程创新,以最经济的方式提升产品体验?

兆欧表电压档位选择_过路老熊_新浪博客

文獻調研(三):數據驅動的建築能耗預測模型綜述

手工制作 pl-2303hx 的USB转TTL电平串口的电路_过路老熊_新浪博客

使用百度地图API在地图中设置一个覆盖物(InfoWindow),可自定义窗口内容

猕猴桃酵素的功效_过路老熊_新浪博客

6. common instructions (upper) v-cloak, v-once, v-pre

The role of iomanip header file in actual combat

关于运行scrapy项目时提示 ModuleNotFoundError: No module named 'pymongo‘的解决方案

unsigned与signed之大白话
随机推荐
Studio5k v28安装及破解_过路老熊_新浪博客
Building cloud computers with FRP
Read CSV file data in tensorflow
Talk about the copy on write mechanism of PHP variables or parameters
记录一下刷LeetCode瞬间有思路的一道简单题——剑指 Offer 09. 用两个栈实现队列
Px4 multi computer simulation (gazebo)
Apache Doris1.0版本集群搭建、负载均衡与参数调优
Backup restore of xtrabackup
Stop eating vitamin C tablets. These six fruits have the highest vitamin C content
postman如何测试需要登录的接口
Jenkins releases PHP project code
用frp搭建云电脑
php中使用google protobuf协议环境配置
SSM整合学习笔记(主要是思路)
利用swiper实现轮播图
Talk about singleton mode!
Can I upload pictures without deploying the server?
文獻調研(三):數據驅動的建築能耗預測模型綜述
关于二分和双指针的使用
在win10下使用visual studio2015链接mysql数据库