- add script to generate reverse dns zones
This commit is contained in:
Stanislav Ievlev
2009-03-03 18:00:49 +03:00
parent e1acee9c9e
commit 42aceb0382
2 changed files with 55 additions and 2 deletions

View File

@ -1,8 +1,8 @@
%define _altdata_dir %_datadir/alterator
Name: alterator-net-common
Version: 0.5
Release: alt5
Version: 0.6
Release: alt1
Packager: Stanislav Ievlev <inger@altlinux.org>
@ -34,6 +34,9 @@ helpers for etcnet administration
%_libexecdir/%name/
%changelog
* Tue Mar 03 2009 Stanislav Ievlev <inger@altlinux.org> 0.6-alt1
- add script to generate reverse dns zones
* Thu Jan 22 2009 Vladislav Zavjalov <slazav@altlinux.org> 0.5-alt5
- fix typo (by inger@)

View File

@ -0,0 +1,50 @@
#!/bin/sh -efu
ip="${1%%/*}"
mask="${1##*/}"
rdns_net()
{
local net="$1";shift
local pos="$1";shift
local inc="$1";shift
local IFS='.'
set -- $net
case "$pos" in
1)
printf "%s\n" "$(( $1 + $inc ))"
;;
2)
printf "%s.%s\n" "$(( $2 + $inc ))" "$1"
;;
3)
printf "%s.%s.%s\n" "$(( $3 + $inc ))" "$2" "$1"
;;
esac
}
net="$(netname "$ip/$mask"|cut -f1)"
net="${net%%/$mask}"
if [ "$mask" -gt 0 -a "$mask" -le 8 ];then
nmask=8
pos=1
elif [ "$mask" -gt 8 -a "$mask" -le 16 ];then
nmask=16
pos=2
elif [ "$mask" -gt 16 -a "$mask" -le 24 ];then
nmask=24
pos=3
else
mask=24
nmask=24
pos=3
fi
num="$(( 2**($nmask - $mask) - 1 ))"
for i in `seq 0 $num` ;do
rdns_net "$net" "$pos" "$i"
done