In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-10 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Foreword:
IP address service is automatically distributed, and linux server is mainly used in local area network.
If you are in a wide area network, you need to use routing equipment
1: understand DHCP Service 1.1 DHCP brief introduction DHCP (Dynamic Host Configuration Protocol, dynamic Host configuration Protocol) is a protocol designed and developed by the Internet task force to automatically assign TCP/IP parameters to computers in TCP/IP networks.
1.2 the role of DHCP 1.2.1 benefits of using DHCP 1. Reduce the workload of administrators 2. Avoid IP address conflicts 3. When the network changes the IP address range, there is no need to reconfigure each user's IP address 4. 5. The utilization rate of IP address is improved by 5. 5. Convenient client configuration 1.2.2 DHCP allocation method 1. Automatic allocation: permanently use 2. 0 after assigning an IP address. Manual assignment: the DCP server administrator specifically specifies the IP address 3. Dynamic allocation: release the IP after use for use by other clients
For example, the network printer in the local area network is set up for automatic allocation and permanent use.
1.2.3 get the release address command in windows
In windows
command ipconfig / release release ip address
command ipconfig / renew to regain the address
1.3The lease process of DHCP the process by which the client obtains the IP address from the DHCP server is called the DHCP lease process 1.3.1 the lease process is divided into four steps
(1) the client searches the DHCP server in the network.
The client requests the IP address, looks for the DHCP server, and sends DHCP's discover: the first search is broadcast
(2) the server responds to the client service
The server responds by sending the offer of the DHCP to the client-also a broadcast, which contains the ip address resource pool to be used by the client and the corresponding lease; because the client does not have IP at this time, it is still broadcast
(3) the client sends a service request to the target server
The client selects the IP address and sends the DHCP request request to the server: at this point, the client knows the IP address it will use in the future, and then broadcasts the request to confirm whether the ip address is available
(4) the server provides services to the client
The server determines the lease and sends the ACK; of DHCP to the client. When the client receives the ACK, the DHCP addressing process ends and the IP address is configured successfully:-still broadcast, the DHCP server sends the ack to the client for confirmation
Client requests IP address
Server response
The client chooses the IP address
The server determines the lease
1.3.2 Summary: all four processes are broadcast
Dicover broadcasts look for servers that provide DHCP
Offer: source address, destination address 255.255.255.255
available IP address (determined later), related lease term 8 days
Request: request confirmation. If it is not used, ack will be returned. If it is occupied by another host, offer will be sent again.
Ack: if there are multiple DHCP servers in the same network segment, whoever sends ack first will use the IP resource pool.
Dhcp agreement: renewal is applied for more than half of the time, and the 8 days of renewal will be recalculated from now on.
1.4 DHCP's process of re-obtaining ip-when re-logging in
If the previously used ip is not occupied, the server will ack confirm, if it is used, the nack will deny it, and the host will resend the first phase of the broadcast discover
1.5 renew lease when the lease term of the IP address leased by the DHCP server to the client reaches 50%, the client needs to update the DHCP Request packet directly to the server providing the lease, requiring the existing address lease to be updated
If the DHCP server is not found when renewing the lease, continue to use it, continue to use it for the duration of the lease, release it automatically when it expires, and then obtain a new address (when dhcp automatic acquisition is turned on) 169.254.0.0-168.254.255.255
Second: use DHCP to dynamically configure host address 2.1 DHCP service to automatically assign addresses for a large number of clients Provide centralized management of the corresponding network address, broadcast address default gateway address DNS service address 2.2 install DHCP server dhcp-4.2.5-47.e17.centos.x86_64.rpmdhcp software package on the Centos CD-ROM main file main configuration file: / etc/dhcpd.conf executor: / usr/sbin/dhcpd, / usr/sbin/dhcrelay execution parameter configuration: / etc/sysconfig/dhcpd [root@dabendan Packages] # yum install dhcp*-y 'install' [root@dabendan Packages] # cd / etc/dhcp/ [root@dabendan dhcp] # lsdhclient.d dhclient-exit-hooks.d dhcpd6.conf dhcpd.conf scripts [root@dabendan dhcp] # vim dhcpd.conf 'enter configuration file' # # DHCP Server Configuration file.# see / usr/share/doc/dhcp*/dhcpd.conf. Example'to view the case file'# see dhcpd.conf (5) man page#~ [root@dabendan dhcp] # cp- p / usr/share/doc/dhcp-4.2.5/dhcpd.conf.example / etc/dhcp/dhcpd.confcp: do you want to overwrite "/ etc/dhcp/dhcpd.conf"? Y
Core: main configuration file-/ etc/dhcp/dhcpd.conf
/ usr/share/doc/dhcp-4.2.5/dhcpd.conf.example template needs to be overwritten to / etc/dhcp/dhcpd.conf when is configured for the first time
The execution parameter configuration is a source file, so you don't need to move it.
2.3 Global profile settings for the main profile / etc/dhcp/dhcpd.conf
Option routers Gateway
Default time default lease term
Host ns fixed ip address, to add mac address
Ddns-update-style interim; 'temporary update' subnet 10.5.5.0 netmask 255.255.255.224 {'subnet network segment netmask subnet mask, that is, network segment statement' range 10.5.5.26 10.5.5.30; 'range range, configuration option' option domain-name-servers ns1.internal.example.org; 'Select dns server domain name, or IP address' option domain-name "internal.example.org" 'select domain name' option routers 10.5.5.1; 'Select route' option broadcast-address 10.5.5.31; 'select network number' default-lease-time 600; 'default lease term' max-lease-time 7200; 'maximum lease term'} host ns {'ns hostname 'hardware ethernet 08:00:07:26:c0:a5 'fixed MAC address' fixed-address 207.175.42.254; 'fixed IP address, host life'}
1. Prohibit dynamic updates
two。 The default lease term is 21600 seconds
3. The maximum lease term is 43200
4. Specify domain name options domain name
5. Specify the assigned DNS address domain name service
Subnet segment
Range (address pool) start address end address
chooses subnet mask
Select Gateway
Dns can be set in the subnet segment, with a higher priority than the global setting
[root@dabendan dhcp] # vim / etc/dhcp/dhcpd.conf # A slightly different configuration for an internal subnet.subnet 10.5.5.0 netmask 255.255.255.224 {range 10.5.5.26 10.5.5.30; option domain-name-servers ns1.internal.example.org; option domain-name "internal.example.org"; option routers 10.5.5.1; option broadcast-address 10.5.5.31; default-lease-time 600; max-lease-time 7200 } host host declaration hardware ethernet parameter: specify the mac address fixed-address parameter of the corresponding host: specify the IP address reserved for the host host passacaglia {hardware ethernet 0VOV 0VOV 5dLV bdLV 95; filename "vmunix.passacaglia"; server-name "toccata.fugue.com";}
Haedware ethernet to configure the MAC address of the host
Fixed (fixed)-address fixed ip address
Host passacaglia {hardware ethernet 0VOV 0VOV 5dJV BD 95; 'MAC address of the host to configure' filename "vmunix.passacaglia"; server-name "toccata.fugue.com";} III: start the DHCP service
View / var/lib/dhcpd/dhcpd.leases file
[root@dabendan dhcp] # vim / var/lib/dhcpd/dhcpd.leases
Information will not be written in the lease file until the service is enabled
# The format of this file is documented in the dhcpd.leases (5) manual page.# This lease file was written by isc-dhcp-4.2.5lease 192.168.100.11 {'assigned client IP' starts 3 2019-11-20 09 IP' starts 0515;' lease related time 'ends 3 2019-11-20 09 IP' starts 13 35; tstp 3 2019-11-20 09 IP' starts 13 35; cltt 3 2019-11-20 09 ends 0515; binding state free Hardware ethernet 00:0c:29:d6:c0:8a 'client mac address'} 3.1 configure DHCP to enable the client to obtain the IP address 3.1.1 two ways to modify the network card configuration file (ifcfg-ens33) BOOTPROTO=dhcp [root@test01 dhcpd] # vim / etc/sysconfig/network-scripts/ifcfg-ens33TYPE= "Ethernet" PROXY_METHOD= "none" BROWSER_ONLY= "no" BOOTPROTO= "dhcp" DEFROUTE= "yes" IPV4_FAILURE_FATAL= "no" IPV6INIT= "yes" IPV6_AUTOCONF= "yes" IPV6_DEFROUTE= "yes" IPV6_ FAILURE_FATAL= "no" IPV6_ADDR_GEN_MODE= "stable-privacy" NAME= "ens33" UUID= "0f432513-5d7a-455c-88b4-257a9a1dbb45" DEVICE= "ens33" ONBOOT= "yes"
The second uses the dhclient command
Dhclient [- d] [network interface name]
[root@test01 dhcpd] # dhclient-d ens33Internet Systems Consortium DHCP Client 4.2.5Copyright 2004-2013 Internet Systems Consortium.All rights reserved.For info Please visit https://www.isc.org/software/dhcp/Listening on LPF/ens33/00:0c:29:d6:c0:8aSending on LPF/ens33/00:0c:29:d6:c0:8aSending on Socket/fallback'DHCPDISCOVER' on ens33 to 255.255.255.255 port 67 interval 7 (xid=0x75b88e50) 'single quotation marks are added by myself' 'DHCPREQUEST' on ens33 to 255.255.255.255 port 67 (xid=0x75b88e50)' DHCPOFFER' from 192.168.100.100DHCPNAK from 192. 168.139.254 (xid=0x75b88e50) 'DHCPACK' from 192.168.100.100 (xid=0x75b88e50) bound to 192.168.100.11-- renewal in 272 seconds.
View log file records
Four: experiment-DHCP Relay principle
5: configuration file summary 5.1 main configuration file: / etc/dhcp/dhcpd.conf
You need to overwrite the template file / usr/share/doc/dhcp-4.2.5/dhcpd.conf.example to / etc/dhcp/dhcpd.conf for the first time
Setting parameters in the main configuration file # global configuration parameter option routers; # gateway default-lease-time; # default lease term option domain-name-servers DNS server domain name or hostname; max-lease-time 7200 role # maximum lease term ddns-update-style interim # temporarily update subnet 192.168.10.0 netmask 255.255.255.0 {# IP address pool of network segment subnet mask range 192.168.10.1 192.168.10.254 address pool from to option domain-name-servers DNS server domain name or hostname; # DNS specifies option domain-name "domain name"; # specifies domain name option routers 192.168.10.1 # specify the gateway option broadcast-address 192.168.10.255 # specify the network number default-lease-time 600 X # default lease term max-lease-time 7200 X # maximum lease term} host ns {# ns hostname host host declaration, acting on a single host hardware ethernet 00VlV 0000VV 00VV 00X # specify the mac address fixed-address 192.168.10.88 # declare the fixed ip address of the host option subnet-mask 192.168.10.1; # specify the subnet mask server-name "domain name"; # specify the server name} 5.3 / var/lib/dhcpd/dhcpd.leases lease file
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.