Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Shell script swipes into simple DHCP and DNS services with one click (interested can come in and have a look)

2025-04-03 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/03 Report--

Swipe into the simple DHCP service this script configuration: the static IP address of the server is 192.168.100.100 (only this point needs to be customized) #! / bin/bash# one-button automatic DHCPyum install dhcp-y wangka= "/ etc/sysconfig/network-scripts/ifcfg-ens33" # configuration file location sed-I-e'/ BOOTPROTO/s/dhcp/static/g'-e'/ ONBOOT/aIPADDR=192.168.100.100\ nNETMASK=255.255 .255.0\ nGATEWAY=192.168.100.1' $wangkasystemctl restart network# modifies the static IP address muban= "/ usr/share/doc/dhcp-4.2.5/dhcpd.conf.example" peizhi= "/ etc/dhcp/dhcpd.conf" [!-e "$peizhi.bak"] & & cp $peizhi $peizhi.bak# to determine whether there is a backup of the configuration file If not, back up cp $muban $peizhised-I '29asubnet 192.168.100.0 netmask 255.255.255.0 {\ nrange 192.168.100.120 192.168.100.150\ \ n option routers 192.168.100.1\;\ n}'$peizhisystemctl start dhcpdsystemctl stop firewalldsetenforce 'turns on the service and turns off the firewall and enhanced security features by swiping into the simple DNS forward resolution service script configuration: server IP address: 192.168.116.131 bind Bash & > / dev/null# one button DNSrpm-Q bindif [$?-ne 0] Whether the then yum install bind-y systemctl start namedfi#DNS service installs read-p "custom domain name (example: test.com)" yuquanju= "/ etc/named.conf" quyu= "/ etc/named.rfc1912.zones" [!-e $quanju.bak] & & cp $quanju $quanju.bak sed-I-e '13s quanju 127.0.0.1 and 192.168.116.131max'-e '21s quanju 'any quanju [! -e $quyu.bak] & & cp $quyu $quyu.bak# backup global, Zone profile grep "$yu" $quyu & > / dev/nullwhile [$?-ne 0] Do sed-I "18azone\" $yu\ "IN {\ n type master\;\ nfile\" $yu.dns\ "\;\ n}\;\ n" $quyu peizhi= "/ var/named/$yu.dns" cp-p / var/named/named.localhost $peizhidone# to determine whether the domain name exists. If it does not exist, add sed-I-e '2d'-e "1a @ IN SOA" $yu. Admin. "$yu"\. ("/ var/named/$yu.dnssed-I '8d' / var/named/$yu.dnssed-I' $d' / var/named/$yu.dnssed-I-e" 7a\ NS $yu. "- e" / A/s/127.0.0.1/192.168.116.131/ "/ var/named/$yu.dns# modify the area file while [1-ge 0] Do read-p "Please enter a custom pointer A record (example: www IN A 8.8.8.8)" zhen echo $zhen > > / var/named/$yu.dns read-p "whether to continue to add" an if [$a! = "y"]; then breakfidone# loop systemctl restart namedjieguo= `systemctl status named | grep "active" & > / dev/ null`if [$?-eq 0] Then echo "Service start" else echo start failed "fi# determines whether the service can start sed-I's hand 116.2hand 116.131G' / etc/resolv.conf# for self-test

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report