Get the App
SLTechnology News&Howtos  ›  Servers  › 

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

Shulou Source: shulou.com Published: 2022-06-03 04:27:08 12月06日 Update

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

Tags: Service configuration one-click file address backup script zone instance ownership server static security location global function only domain name domain definition domain pointer Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB Microsoft Shulou Tech Info vpn Linux