In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-09-21 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/02 Report--
Experimental environment: set the native IP to 192.168.100.100, and the script code is as follows:
The replicable code is as follows:
#! / bin/bashyum install dhcp- ynetwork= "/ etc/sysconfig/network-scripts/ifcfg-ens33" dhcp= "/ etc/dhcp/dhcpd.conf" [!-e $network.bak] & & cp- p $network $network.baksed-I-e "4s/dhcp/static/"-e'$aIPADDR=192.168.100.100\ nNETMASK=255.255.255.0\ nGATEWAY=192.168.100.1' $networksystemctl restart networkcp-p / usr/share/doc/dhcp-4.2.5/dhcpd.conf.example $dhcp [!-e $dhcp.bak] & & cp-p $dhcp $dhcp.baksed-I-e "29asubnet 192.168.100.0 netmask 255.255.255.0 {\ nrange 192.168.100.10 192.168.100.50 \ n option routers 192.168.100.1;\ n} "$dhcpsystemctl start dhcpd detailed explanation
First perform variable assignment, assign value to network and dhcp variable names
1. ``[!-e $network.bak] & & cp-p $network $network.bak
Determine whether the network file has been backed up, and perform a backup operation if there is no backup
2. Sed-I-e "4s/dhcp/static/"-e'$aIPADDR=192.168.100.100\ nNETMASK=255.255.255.0\ nGATEWAY=192.168.100.1' $network
Systemctl restart network
Change the IP address type in the network file to static, and add IPADDR=192.168.100.100 at the last line, followed by a new line with "\ n"; add NETMASK=255.255.255.0, and then use another line; add GATEWAY=192.168.100.1
3 、 systemctl restart network
Restart network services
4. Cp- p / usr/share/doc/dhcp-4.2.5/dhcpd.conf.example $dhcp
Copy the dhcp sample configuration file to the dhcp configuration file to achieve full coverage.
5. [!-e $dhcp.bak] & & cp-p $dhcp $dhcp.bak
Determine whether the dhcp configuration file has been backed up, and perform a backup operation if there is no backup
6. Sed-I-e "29asubnet 192.168.100.0 netmask 255.255.255.0 {\ nrange 192.168.100.10 192.168.100.50
Add network segments, subnet masks, gateways and the range of ip addresses that can be given to the dhcp configuration file (can be changed as needed)
7 、 ssystemctl start dhcpd
Enable the dhcpd service
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.
The market share of Chrome browser on the desktop has exceeded 70%, and users are complaining about
The world's first 2nm mobile chip: Samsung Exynos 2600 is ready for mass production.According to a r
A US federal judge has ruled that Google can keep its Chrome browser, but it will be prohibited from
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
About us Contact us Product review car news thenatureplanet
More Form oMedia: AutoTimes. Bestcoffee. SL News. Jarebook. Coffee Hunters. Sundaily. Modezone. NNB. Coffee. Game News. FrontStreet. GGAMEN
© 2024 shulou.com SLNews company. All rights reserved.