In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-25 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
1, dynamic host configuration protocol
Dynamic Host configuration Protocol (DHCP,Dynamic Host Configuration Protocol), which is used to automatically manage parameters such as IP address, subnet mask, gateway address and DNS address of hosts in the LAN
It can effectively improve the utilization of IP addresses, improve the configuration efficiency, and reduce the cost of management and maintenance; a network protocol based on UDP protocol and limited to use within the local area network, mainly used in large-scale local area network environment or local area network environment with more mobile office devices
Its main purpose is to automatically assign parameters such as IP addresses to devices or network providers within the local area network. To put it simply, the DHCP protocol is to let the hosts in the local area network get the service of network parameters automatically. If you manually configure the network parameters of each host, it will be very troublesome, and it will be difficult to maintain in the future.
And when the number of hosts in the computer room increases further (for example, there are 100 or even 1000), the workload of manual configuration and maintenance is enough to make the operation and maintenance staff collapse.
With the help of DHCP protocol, we can not only automatically assign network parameters to the host, but also ensure that the IP address used by the host is unique, and more importantly, a fixed IP address can be assigned to a specific host.
DHCP services include the following common terms:
Scope: a complete IP address range, according to which the DHCP protocol manages the distribution of the network, assigns IP addresses, and other configuration parameters.
Super scope: used to manage multiple logical subnet segments in the same physical network. The super scope contains a list of scopes that can be managed uniformly.
Exclude scope: exclude some IP addresses in the scope to ensure that these IP addresses are not assigned to DHCP clients.
Address pool: after defining the scope of the DHCP and applying the exclusion range, the rest is used to dynamically assign the IP address range to the DHCP client.
Lease: the time during which a DHCP client can use a dynamically assigned IP address.
Reservation: make sure that specific devices in the network always get the same IP address.
2. Deploy the dhcpd service program
2-1 dhcpd is a service program used to provide DHCP protocol in Linux system. Although the function of DHCP protocol is very powerful, the configuration steps of dhcpd service program are very simple, which greatly reduces the threshold of implementing dynamic host management service in Linux.
After confirming that the Yum software repository is configured, install the dhcpd service program:
The parameter yum-y install dhcp-y defaults to yes
View the contents of the main configuration file of the dhcpd service program:
Cat / etc/dhcp/dhcpd.conf
DHCP Server Configuration file. # see / usr/share/doc/dhcp*/dhcpd.conf.example # see dhcpd.conf (15) man page
Only this 3-line comment statement, here we can compile freely, you can also refer to the sample file on line 2.
2-2, a standard configuration file should include global configuration parameters, subnet segment declarations, address configuration options, and address configuration parameters. The global configuration parameter is used to define the overall running parameters of the dhcpd service program.
The subnet segment declaration is used to configure the address properties of the entire subnet segment. Considering that there are many parameters available to the dhcpd service program configuration file, the following are the most commonly used parameters:
Ddns-update-style [type] defines the types of dynamic updates for DNS services, including none (not supported for dynamic updates), interim (interactive update mode) and ad-hoc (special update mode).
[allow | ignore] client-updates allows / ignores clients to update DNS records
Default-lease-time [21600] default timeout
Max-lease-time [43200] maximum timeout
Option domain-name-servers [8.8.8.8] defines the DNS server address
Option domain-name ["domain.org"] defines the DNS domain name
Range 0.0.0.0 0.0.0.0 defines the IP address pool for allocation
Option subnet-mask defines the subnet mask of the client
Option routers defines the gateway address of the client
Broadcase-address [broadcast address] defines the broadcast address of the client
Ntp-server [IP address] defines the network time server (NTP) of the client
Nis-servers [IP address] defines the address of the client's NIS domain server
Hardware [Network Card physical address] specifies the interface type and MAC address of the network card.
Server-name [hostname] notifies the DHCP client of the hostname of the DHCP server
Fixed-address [IP address] assigns a fixed IP address to a specified host
3. Automatically manage IP addresses
The original purpose of DHCP protocol is to manage IP address resources in local area network more efficiently. The DHCP server automatically assigns network information such as IP address, subnet mask, gateway, DNS address to clients in need.
Moreover, when the lease time of the client expires, the assigned IP address can be automatically recycled so that it can be handed over to the new client.
3-1, let's do an experiment to configure the dhcp server and use the client to get the IP assigned by the dhcp server
Turn off the DHCP service on the virtual machine to avoid conflicts. Both the server and the client should use host-only mode, otherwise they will not be able to obtain IP
Edit the main configuration file and note that all parameters end with a semicolon (;). This is the rule.
Vim / etc/dhcp/dhcpd.conf
Ddns-update-style none; sets the DNS service not to update
Ignore client-updates; ignores client update DNS
Subnet 192.168.13.0 netmask 255.255.255.0 {Network segment with scope of 192.168.13.0 netmask 24
Range 192.168.13.131 192.168.13.133; address pool 192.168.13.131-133 (a total of 3 IP)
Option routers 192.168.13.1; defines the gateway of the client
Option subnet-mask 255.255.255.0; define the subnet mask of the client
Option domain-name "rehl.wyw.com"; defines the default search domain
Option domain-name-servers 192.168.13.128; defines the DNS address of the client
Default-lease-time 21600; define the default lease time
Max-lease-time 43200; define the maximum appointment time
} Terminator
3-2, in the Red Hat certification exam and production environment, the configured dhcpd service needs to be added to the boot item to ensure that the dhcpd service can still start automatically after the next boot of the server, and smoothly assign IP address and other information to the client.
It is sincerely recommended that everyone form the good habit of "configuring the service program and easily adding the boot item":
Systemctl restart dhcpd restarts the dhcp service
Systemctl enable dhcpd add boot startup item
3-3. If the client restarts the Nic, you can see the IP address we obtained.
You can also use the windows system to get under, their own operation!
4. Assign a fixed IP address
In the DHCP protocol, there is a term "reservation", which is used to ensure that specific devices in the LAN always get a fixed IP address. In other words, the dhcpd service program will reserve an IP address and use it only for the specific device that matches.
To bind an IP address to a host, you need to use the host's MAC address. The MAC address is a string of independent identifiers on the network card, which is unique, so there will be no conflicts:
In both Linux and Windows systems, you can learn the MAC address of the host by looking at the status of the network card. In the configuration file of the dhcpd service program, bind the IP address to the MAC address in the following format.
4-1, sometimes we can't get the MAC address because we are inconvenient or afraid to check the leader's computer, so we can use the dhcp service to get the IP address automatically, and then we can check the IP address assignment record in the log and get the MAC address.
Tail-f / var/log/messages cycle reads the log file and looks at the MAC address
4-2, add a configuration file to bind the MAC address to the fixed IP to be assigned
Vim / etc/dhcp/dhcpd.conf
Host REHL7.COM {Hostname
Hardware ethernet 00:0c:29:74:a1:c6; the MAC address of the host
Fixed-address 192.168.13.132; IP to be assigned
} Terminator
4-3, restart the network card service on the client, check the IP, and successfully get the fixed IP.
Systemctl restart network
Ifconfig
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.