Description
I use the Red Hat 6.5 system, IP is 172.24.10.107 can ping out of the network, although in practice, but there is no use, but for learning shell programming and school exams are very useful, nonsense not to say, on the code:
#!/bin/bash#2017-11-11#by-#centos6.5name= "duwentao.com" rip=10.24.172ip=172.24.10.107named= "/etc/named.conf" Zheng= "/var/named/$name. Zone" fan= "/var/named/$rip. In-addr.arpa.zone" #判断DNS软件是否安装, if installed, uninstall and reinstall, install if if not installed [ ! -f $named ];thenyum install bind* -yelseyum remove bind * -yyum install bind* -y fi# Configuring the Master file rm -rf $namedtouch $namedcat >> $named << +end+options {listen-on port 53 { any; } listen-on-v6 port 53 { ::1; };d irectory "/var/named";d ump-file "/var/named /data/cache_dump.db "; statistics-file "/var/named/data/ Named_stats.txt "; memstatistics-file "/var/named/data/ Named_mem_stats.txt ";allow-query { any; };recursion yes; Dnssec-enable no;dnssec-validation no;/* path to isc dlv key */bindkeys-file "/etc/ Named.iscdlv.key ";managed-keys-directory "/var/named/dynamic ";}; logging { channel default_debug { file "Data/named.run" ; severity dynamic; };}; zone "." IN {type hint;file "named.ca";}; zone "$name" IN{type master;file "$zheng";}; zone "$rip. In-addr.arpa" IN{type master;file "$fan";}; include "/etc/named.rfc1912.zones";include "/etc/named.root.key"; +end+ #配置正向解析文件if [ ! -f $zheng ];thentouch $zhengelserm -rf $zhengtouch $zhengficat >> $zheng &NBSP;<< +end+\ $TTL 1D@IN SOA $name root $name . (0; serial1d; refresh1h; retry1w; expire3h ); minimum@ in NS dns.smile.com.dns IN A $ipmail IN A $ipwww IN A $ip +end+ #配置反向解析文件if [ ! -f $fan ];then touch $fanelse rm -rf $ fan touch $fanficat >> $fan << +end+\ $TTL 86400@IN SOA $rip in-addr.arpa. root $name . (0; serial1d; Refresh1h; retry1w; expire3h ); minimum@ in ns dns. $name. 107 in ptr www.$ Name.107 in ptr mail. $name. +END+chgrp named $named chgrp named $zhengchgrp named $fanecho "nameserver 172.24.10.107" >> /etc/resolv.confservice named restart
Execution process:
Part of this procedure that I think is important
1,if statements
if []; Then statement 1 Else statement 2fi
2, INSERT statement
Cat >> File << +end+ The statement to be inserted note that cat >> is append cat > to empty the contents of the source file and add +end
3, logical operators
-F
|
Determine if a file exists |
Eg:if [-f filename]
|
-D |
Determine if a directory exists |
eg:if [-D dir] |
4, variable
The Shell programming language is a non-type interpreted language, and the shell assigns a variable to it, which in fact defines the variable, which can be assigned to a variable (=) in all Linux-supported shells.
SHELL variables can be divided into two categories: local variables and environment variables. Local variables are only used in shell scripts that create them. Environment variables can be used in the shell in which they are created and in any child processes it derives from. Some variables are created by the user, while others are private shell variables.
Welcome to my public number, study with me
650) this.width=650; "Src=" Https://s5.51cto.com/oss/201711/11/56bfced931d3fd553ccff2c4cbc87d47.jpg-wh_500x0-wm_3 -wmp_4-s_1050103347.jpg "title=" qrcode_for_gh_0cd223682950_344.jpg "alt=" 56bfced931d3fd553ccff2c4cbc87d47.jpg-wh _ "/>
This article is from the "Tiandaochouqin" blog, make sure to keep this source http://tdcqvip.blog.51cto.com/12995943/1980923
Automatic deployment of DNS scripts under Linux