当前位置:网站首页>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
边栏推荐
- Common knowledge points in JS
- Hand made pl-2303hx USB to TTL level serial port circuit_ Old bear passing by_ Sina blog
- Apache Doris1.0版本集群搭建、负载均衡与参数调优
- 谈一谈生产环境中swoole协程创建数量控制机制
- Can I upload pictures without deploying the server?
- 谈一谈PHP变量或参数的Copy On Write机制
- Search rotation array ii[Abstract dichotomy exercise]
- 手工制作 pl-2303hx 的USB转TTL电平串口的电路_过路老熊_新浪博客
- One article explains R & D efficiency! Your concerns are
- JS中的数字数组去重
猜你喜欢

Some common operation methods of array

Connecting MySQL database with VBScript_ Old bear passing by_ Sina blog

支付宝支付接口沙箱环境测试以及整合到一个ssm电商项目中

如何配置SQL Server 2008管理器_过路老熊_新浪博客

Efficacy of kiwi fruit enzyme_ Old bear passing by_ Sina blog

Studio5k v28安装及破解_过路老熊_新浪博客

关于scrapy爬虫时,由spider文件将item传递到管道的方法注意事项

Summary of c++ references and pointers

6. common instructions (upper) v-cloak, v-once, v-pre
![Find the minimum value of flipped array [Abstract bisection]](/img/b9/1e0c6196e6dc51ae2c48f6c5e83289.png)
Find the minimum value of flipped array [Abstract bisection]
随机推荐
DPVS-FullNAT模式keepalived篇
兆欧表电压档位选择_过路老熊_新浪博客
在step7中实现模拟量数值与工程量数值之间的转换_过路老熊_新浪博客
Some common operation methods of array
搜索旋转数组II[抽象二分练习]
Talk about the copy on write mechanism of PHP variables or parameters
Use Baidu map API to set an overlay (infowindow) in the map to customize the window content
Talk about how to hot restart a spoole or PHP cli process
JS中的原型链面试题--Foo和 getName
6.常用指令(上)v-cloak,v-once,v-pre
猕猴桃酵素的功效_过路老熊_新浪博客
用frp搭建云电脑
使用npm创建并发布包时遇到的常见问题
[转载]RSLOGIX 5000实例教程
我的博客今天2岁167天了,我领取了先锋博主徽章_过路老熊_新浪博客
Final and static
Bit Compressor [蓝桥杯题目训练]
文獻調研(三):數據驅動的建築能耗預測模型綜述
Analyse des cinq causes profondes de l'échec du développement de produits
Jenkins 发布PHP项目代码