Add reverse scripts
Signed-off-by: Fabian Bläse <fabian@blaese.de>
This commit is contained in:
parent
4654ff0d53
commit
b8279fbc1e
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
|
||||
#Name der Zone
|
||||
DomainZone="50.10.in-addr.arpa."
|
||||
#Positionen und Namen der Forward Lookup Zone Files
|
||||
ForwardZoneFiles=("/srv/fff-dns/db.fff.community")
|
||||
ReverseZoneFile="/var/lib/bind/db.50.10"
|
||||
#Temporäres Verzeichnis - muss pro Zone exclusiv sein!
|
||||
TempDir="/tmp/50.10.in-addr.arpa"
|
||||
#TTL
|
||||
TTL=3600
|
||||
#refresh
|
||||
refresh=2000
|
||||
#retry
|
||||
retry=6400
|
||||
#expire
|
||||
expire=2419200
|
||||
#minimum
|
||||
minimum=86400
|
||||
#contact-mail
|
||||
contact=franken.freifunk.net.
|
||||
#responsible DNS Server by name (for reverseDNS your own)
|
||||
responsible=aquarius.gw.fff.community.
|
||||
|
||||
#################################################################
|
||||
|
||||
function dnsreload {
|
||||
systemctl reload bind9
|
||||
}
|
||||
|
||||
function validate_ip() {
|
||||
local ip=$1
|
||||
local stat=1
|
||||
|
||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
OIFS=$IFS
|
||||
IFS='.'
|
||||
ip=($ip)
|
||||
IFS=$OIFS
|
||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
||||
stat=$?
|
||||
fi
|
||||
return $stat
|
||||
}
|
||||
|
||||
|
||||
mkdir -p $TempDir
|
||||
Serials=()
|
||||
for ForwardZoneFile in "${ForwardZoneFiles[@]}"
|
||||
do
|
||||
ZoneName=$(cat $ForwardZoneFile | grep SOA | awk '{ print $1 }' | head -n 1)
|
||||
named-compilezone -o "$TempDir/$ZoneName" $ZoneName $ForwardZoneFile >/dev/null 2>&1
|
||||
serial=$(cat "$TempDir/$ZoneName" | grep SOA | awk '{ print $7 }' | head -n 1)
|
||||
Serials+=( "$serial" )
|
||||
done
|
||||
|
||||
Serials=( $( for i in ${Serials[@]}; do echo "$i"; done | sort -rn ) )
|
||||
serial=${Serials[0]}
|
||||
|
||||
echo "$DomainZone $TTL IN SOA $responsible $contact $serial $refresh $retry $expire $minimum" > "$TempDir/$DomainZone"
|
||||
echo "$DomainZone $TTL IN NS $responsible" >> "$TempDir/$DomainZone"
|
||||
for ForwardZoneFile in $(ls $TempDir)
|
||||
do
|
||||
Hosts=($(cat "$TempDir/$ForwardZoneFile" | grep -v SOA | awk '{ print $1 }'))
|
||||
IPs=$(cat "$TempDir/$ForwardZoneFile" | grep -v SOA | awk '{ print $5 }')
|
||||
i=0
|
||||
for IP in $IPs
|
||||
do
|
||||
if validate_ip $IP
|
||||
then
|
||||
echo $(echo $IP | awk 'BEGIN { FS = "." } ; { print $4 "." $3 "." $2 "." $1 }')".in-addr.arpa." $TTL IN PTR ${Hosts[$i]} >> "$TempDir/$DomainZone"
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
done
|
||||
|
||||
if [ -f $ReverseZoneFile ]; then
|
||||
oldSerial=$(grep SOA $ReverseZoneFile | awk 'NR==1{print $7}')
|
||||
else
|
||||
oldSerial=0
|
||||
fi
|
||||
|
||||
if [ $serial -gt $oldSerial ]
|
||||
then
|
||||
named-compilezone -o $ReverseZoneFile $DomainZone "$TempDir/$DomainZone" >/dev/null 2>&1
|
||||
dnsreload
|
||||
fi
|
||||
rm -r $TempDir
|
|
@ -0,0 +1,89 @@
|
|||
#!/bin/bash
|
||||
|
||||
#Name der Zone
|
||||
DomainZone="83.10.in-addr.arpa."
|
||||
#Positionen und Namen der Forward Lookup Zone Files
|
||||
ForwardZoneFiles=("/srv/fff-dns/db.fff.community")
|
||||
ReverseZoneFile="/var/lib/bind/db.83.10"
|
||||
#Temporäres Verzeichnis - muss pro Zone exclusiv sein!
|
||||
TempDir="/tmp/83.10.in-addr.arpa"
|
||||
#TTL
|
||||
TTL=3600
|
||||
#refresh
|
||||
refresh=2000
|
||||
#retry
|
||||
retry=6400
|
||||
#expire
|
||||
expire=2419200
|
||||
#minimum
|
||||
minimum=86400
|
||||
#contact-mail
|
||||
contact=franken.freifunk.net.
|
||||
#responsible DNS Server by name (for reverseDNS your own)
|
||||
responsible=aquarius.gw.fff.community.
|
||||
|
||||
#################################################################
|
||||
|
||||
function dnsreload {
|
||||
systemctl reload bind9
|
||||
}
|
||||
|
||||
function validate_ip() {
|
||||
local ip=$1
|
||||
local stat=1
|
||||
|
||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
OIFS=$IFS
|
||||
IFS='.'
|
||||
ip=($ip)
|
||||
IFS=$OIFS
|
||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
||||
stat=$?
|
||||
fi
|
||||
return $stat
|
||||
}
|
||||
|
||||
|
||||
mkdir -p $TempDir
|
||||
Serials=()
|
||||
for ForwardZoneFile in "${ForwardZoneFiles[@]}"
|
||||
do
|
||||
ZoneName=$(cat $ForwardZoneFile | grep SOA | awk '{ print $1 }' | head -n 1)
|
||||
named-compilezone -o "$TempDir/$ZoneName" $ZoneName $ForwardZoneFile >/dev/null 2>&1
|
||||
serial=$(cat "$TempDir/$ZoneName" | grep SOA | awk '{ print $7 }' | head -n 1)
|
||||
Serials+=( "$serial" )
|
||||
done
|
||||
|
||||
Serials=( $( for i in ${Serials[@]}; do echo "$i"; done | sort -rn ) )
|
||||
serial=${Serials[0]}
|
||||
|
||||
echo "$DomainZone $TTL IN SOA $responsible $contact $serial $refresh $retry $expire $minimum" > "$TempDir/$DomainZone"
|
||||
echo "$DomainZone $TTL IN NS $responsible" >> "$TempDir/$DomainZone"
|
||||
for ForwardZoneFile in $(ls $TempDir)
|
||||
do
|
||||
Hosts=($(cat "$TempDir/$ForwardZoneFile" | grep -v SOA | awk '{ print $1 }'))
|
||||
IPs=$(cat "$TempDir/$ForwardZoneFile" | grep -v SOA | awk '{ print $5 }')
|
||||
i=0
|
||||
for IP in $IPs
|
||||
do
|
||||
if validate_ip $IP
|
||||
then
|
||||
echo $(echo $IP | awk 'BEGIN { FS = "." } ; { print $4 "." $3 "." $2 "." $1 }')".in-addr.arpa." $TTL IN PTR ${Hosts[$i]} >> "$TempDir/$DomainZone"
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
done
|
||||
|
||||
if [ -f $ReverseZoneFile ]; then
|
||||
oldSerial=$(grep SOA $ReverseZoneFile | awk 'NR==1{print $7}')
|
||||
else
|
||||
oldSerial=0
|
||||
fi
|
||||
|
||||
if [ $serial -gt $oldSerial ]
|
||||
then
|
||||
named-compilezone -o $ReverseZoneFile $DomainZone "$TempDir/$DomainZone" >/dev/null 2>&1
|
||||
dnsreload
|
||||
fi
|
||||
rm -r $TempDir
|
|
@ -0,0 +1,87 @@
|
|||
#!/bin/bash
|
||||
|
||||
#Name der Zone
|
||||
DomainZone="d.b.9.2.2.0.6.5.3.4.d.f.ip6.arpa."
|
||||
#Positionen und Namen der Forward Lookup Zone Files
|
||||
ForwardZoneFiles=("/srv/fff-dns/db.fff.community")
|
||||
ReverseZoneFile="/var/lib/bind/db.fd43-5602-29bd"
|
||||
#Temporäres Verzeichnis - muss pro Zone exclusiv sein!
|
||||
TempDir="/tmp/d.b.9.2.2.0.6.5.3.4.d.f.ip6.arpa"
|
||||
#TTL
|
||||
TTL=3600
|
||||
#refresh
|
||||
refresh=2000
|
||||
#retry
|
||||
retry=6400
|
||||
#expire
|
||||
expire=2419200
|
||||
#minimum
|
||||
minimum=86400
|
||||
#contact-mail
|
||||
contact=franken.freifunk.net.
|
||||
#responsible DNS Server by name (for reverseDNS your own)
|
||||
responsible=aquarius.gw.fff.community.
|
||||
|
||||
#################################################################
|
||||
|
||||
function dnsreload {
|
||||
systemctl reload bind9
|
||||
}
|
||||
|
||||
function validate_ip() {
|
||||
local ip=$1
|
||||
local stat=1
|
||||
|
||||
if [[ $ip =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
||||
OIFS=$IFS
|
||||
IFS='.'
|
||||
ip=($ip)
|
||||
IFS=$OIFS
|
||||
[[ ${ip[0]} -le 255 && ${ip[1]} -le 255 \
|
||||
&& ${ip[2]} -le 255 && ${ip[3]} -le 255 ]]
|
||||
stat=$?
|
||||
fi
|
||||
return $stat
|
||||
}
|
||||
|
||||
|
||||
mkdir -p $TempDir
|
||||
Serials=()
|
||||
for ForwardZoneFile in "${ForwardZoneFiles[@]}"
|
||||
do
|
||||
ZoneName=$(cat $ForwardZoneFile | grep SOA | awk '{ print $1 }' | head -n 1)
|
||||
named-compilezone -o "$TempDir/$ZoneName" $ZoneName $ForwardZoneFile >/dev/null 2>&1
|
||||
serial=$(cat "$TempDir/$ZoneName" | grep SOA | awk '{ print $7 }' | head -n 1)
|
||||
Serials+=( "$serial" )
|
||||
done
|
||||
|
||||
Serials=( $( for i in ${Serials[@]}; do echo "$i"; done | sort -rn ) )
|
||||
serial=${Serials[0]}
|
||||
|
||||
echo "$DomainZone $TTL IN SOA $responsible $contact $serial $refresh $retry $expire $minimum" > "$TempDir/$DomainZone"
|
||||
echo "$DomainZone $TTL IN NS $responsible" >> "$TempDir/$DomainZone"
|
||||
for ForwardZoneFile in $(ls $TempDir)
|
||||
do
|
||||
Hosts=($(cat "$TempDir/$ForwardZoneFile" | grep -v SOA | grep -Fv "*" | awk '{ print $1 }'))
|
||||
IPs=$(cat "$TempDir/$ForwardZoneFile" | grep -v SOA | grep -Fv "*" | awk '{ print $5 }')
|
||||
i=0
|
||||
for IP in $IPs; do
|
||||
if rdns=$(sipcalc -r "$IP" | grep -F "ip6.arpa."); then
|
||||
echo "$rdns $TTL IN PTR ${Hosts[$i]}" >> "$TempDir/$DomainZone"
|
||||
fi
|
||||
i=$((i+1))
|
||||
done
|
||||
done
|
||||
|
||||
if [ -f $ReverseZoneFile ]; then
|
||||
oldSerial=$(grep SOA $ReverseZoneFile | awk 'NR==1{print $7}')
|
||||
else
|
||||
oldSerial=0
|
||||
fi
|
||||
|
||||
if [ $serial -gt $oldSerial ]
|
||||
then
|
||||
named-compilezone -o $ReverseZoneFile $DomainZone "$TempDir/$DomainZone" >/dev/null 2>&1
|
||||
dnsreload
|
||||
fi
|
||||
rm -r $TempDir
|
|
@ -16,8 +16,8 @@ git pull -q --ff-only
|
|||
|
||||
/srv/fff-scripts/10-50-reverse.sh
|
||||
/srv/fff-scripts/10-83-reverse.sh
|
||||
/srv/fff-scripts/fd43-5602-29bd-reverse.sh
|
||||
|
||||
if [ "$oldhash" != "$(git rev-parse HEAD)" ]; then
|
||||
/bin/systemctl reload bind9
|
||||
fi
|
||||
|
||||
|
|
Loading…
Reference in New Issue