⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 make_rev

📁 早期freebsd实现
💻
字号:
#!/bin/sh# @(#) make_rev 1.2 92/08/31 @(#)# make the reverse mapping file from a DNS database## Copyright (c) 1992 by Texas Internet Consulting# This code may be freely copied and used so long as this# copyright notice is attached.  This code may not be sold# without the express written permission of Texas Internet Consulting.# Texas Internet Consulting makes no warranty as to the correctness# nor the applicability of this code for any purpose.DNS_DOMAIN=$1DNS_NETWORK=$2# the reverse  template fileREV_HEAD=hosts.revhead# calculate the reverse domain from the network # the assumption is subnets are divided along byte boundariesDNS_REVDOMAIN=`echo $DNS_NETWORK | awk -F. '{	for (i = NF; i>0; i--) {		if ($i == 0) continue		revdomain = revdomain $i "."	}	revdomain = substr(revdomain, 1, length(revdomain)-1)	print revdomain}'`# update the serial fieldserial=`cat serial`echo "; $serial" >f.${DNS_NETWORK}sed "s/<SERIAL>/$serial/" ${REV_HEAD} >>f.${DNS_NETWORK}# build the reverse mapawk 'BEGIN {	domain = "'${DNS_DOMAIN}'."	reverse = "'${DNS_REVDOMAIN}'"	split(reverse, revbytes, ".")	nrevbytes = 0	for (i in revbytes)		nrevbytes++}/IN A|in a/ {	# hostname is a blank	if ($1 == "IN" && $2 == "A" || $1 == "in" && $2 == "a") {		address = $3	}	# special ugly nasty case - no reverse map for the domain itself	# an A record is added for non-mx mailers, but by convention the	# name of the domain gateway is domain.domain...	else if ($1 == "@") {		next	}	else {		host = $1		address = $4	}	# split the host address apart and reverse it	split(address, byte, ".")	for (i=1; i<=nrevbytes; i++) {		if (byte[i] != revbytes[nrevbytes-i+1])			break	}	# address is in this zone	if (i > nrevbytes) {		rev = ""		for (j=4; j>nrevbytes; j--) {			if (j < 4)				rev = rev "."			rev = rev byte[j]		}		# print the PTR record		# if it end in a "." then do not create a PTR record		if (host !~ /\.$/) {			printf("%s IN PTR ",  rev)			if (host == "")				printf("%s\n", domain)			else				printf("%s.%s\n", host, domain)		}	}}' ${DNS_DOMAIN} >>f.${DNS_NETWORK}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -