From 5b028f5b28abba6e966f193cc9638a7dc112b295 Mon Sep 17 00:00:00 2001 From: Neo_Chen Date: Sun, 26 Apr 2020 19:49:55 +0800 Subject: [PATCH] DNS: generator: loopback address support --- dns/db.10.127 | 48 +++++++++++++++++++------------- scripts/dns-reverse-generator.sh | 29 +++++++++++++++++-- 2 files changed, 55 insertions(+), 22 deletions(-) diff --git a/dns/db.10.127 b/dns/db.10.127 index 7eea0d5..99b7001 100644 --- a/dns/db.10.127 +++ b/dns/db.10.127 @@ -9,15 +9,13 @@ $TTL 604800 ; @ IN NS NeoPDP-11.neo. +; 1.1 IN PTR NeoPDP-11.neo. -1.255 IN PTR NeoPDP-11.neo. 40.1 IN PTR cklvax.neo. 63.1 IN PTR NNPCC.neo. 20.1 IN PTR NeoBOX.neo. 10.1 IN PTR neostorage.neonetwork. 80.1 IN PTR NeoSystem.neo. -80.255 IN PTR NeoSystem.neo. -2.255 IN PTR ucbvax.neo. 1.3 IN PTR pan.neo. 185.8 IN PTR staph.neo. @@ -39,25 +37,14 @@ $TTL 604800 1.8 IN PTR librehs.neo. 2.8 IN PTR blog.librehs.neo. +; DO NOT MANUALLY EDIT THE FOLLOWING LINES ; AUTOGENERATED + +; Tunnel /30 Addresses 1.0 IN PTR ucbvax.caasih.tun30.neo. 2.0 IN PTR caasih.ucbvax.tun30.neo. 9.0 IN PTR NeoSystem.ucbvax.tun30.neo. 10.0 IN PTR ucbvax.NeoSystem.tun30.neo. -10.127.10.1 IN PTR LanTian.pp.neo. -10.127.11.199 IN PTR SUNNET.pp.neo. -10.127.4.254 IN PTR Icecat-Explosion.pp.neo. -10.127.69.1 IN PTR santost12.pp.neo. -10.127.8.185 IN PTR staph.pp.neo. -10.127.8.193 IN PTR JerryXiao.pp.neo. -10.127.8.193 IN PTR JerryXiao.pp.neo. -10.127.8.193 IN PTR JerryXiao.pp.neo. -10.127.8.194 IN PTR JerryXiao-HK1.pp.neo. -10.127.8.194 IN PTR JerryXiao-HK1.pp.neo. -10.127.8.194 IN PTR JerryXiao-HK1.pp.neo. -10.127.8.195 IN PTR JerryXiao-SH1.pp.neo. -10.127.8.195 IN PTR JerryXiao-SH1.pp.neo. -10.127.8.196 IN PTR JerryXiao-HK2.pp.neo. 13.0 IN PTR NeoPDP-11.ucbvax.tun30.neo. 14.0 IN PTR ucbvax.NeoPDP-11.tun30.neo. 17.0 IN PTR NeoPDP-11.caasih.tun30.neo. @@ -118,5 +105,28 @@ $TTL 604800 138.0 IN PTR septs.James58899.tun30.neo. 141.0 IN PTR icecat-jp3.pan.tun30.neo. 142.0 IN PTR pan.icecat-jp3.tun30.neo. -172.20.51.99 IN PTR JerryXiao.pp.neo. -172.22.127.2 IN PTR dfceaef.pp.neo. + +; Point to Point Addresses +1.10 IN PTR LanTian.pp.neo. +1.69 IN PTR santost12.pp.neo. +2.127 IN PTR dfceaef.pp.neo. +99.51 IN PTR JerryXiao.pp.neo. +185.8 IN PTR staph.pp.neo. +193.8 IN PTR JerryXiao.pp.neo. +193.8 IN PTR JerryXiao.pp.neo. +193.8 IN PTR JerryXiao.pp.neo. +194.8 IN PTR JerryXiao-HK1.pp.neo. +194.8 IN PTR JerryXiao-HK1.pp.neo. +194.8 IN PTR JerryXiao-HK1.pp.neo. +195.8 IN PTR JerryXiao-SH1.pp.neo. +195.8 IN PTR JerryXiao-SH1.pp.neo. +196.8 IN PTR JerryXiao-HK2.pp.neo. +199.11 IN PTR SUNNET.pp.neo. +254.4 IN PTR Icecat-Explosion.pp.neo. + +; Loopback Addresses +1.255 IN PTR NeoPDP-11.neo +2.255 IN PTR ucbvax.neo +4.255 IN PTR pan.neo +56.255 IN PTR frank-hsinchu.neo +80.255 IN PTR NeoSystem.neo diff --git a/scripts/dns-reverse-generator.sh b/scripts/dns-reverse-generator.sh index ac53569..abc746c 100755 --- a/scripts/dns-reverse-generator.sh +++ b/scripts/dns-reverse-generator.sh @@ -3,6 +3,10 @@ set -e IPTOOL="$PWD/Misc/C/ip" +TUN30_TEMP="$(mktemp)" +PP_TEMP="$(mktemp)" +LO_TEMP="$(mktemp)" + if [ ! -x "$IPTOOL" ]; then echo "You need to build Misc/C/ip first" exit 1 @@ -24,15 +28,34 @@ for i in *; do upstream_ip=$("$IPTOOL" "$i" 1) downstream_ip=$("$IPTOOL" "$i" 2) + ( print_record "$upstream_ip" "$DOWNSTREAM.$UPSTREAM.tun30.neo." print_record "$downstream_ip" "$UPSTREAM.$DOWNSTREAM.tun30.neo." + ) >> "$TUN30_TEMP" elif [ "$TYPE" = "PP" ]; then i="${i/PP,/}" upstream_ip="${i%~*}" downstream_ip="${i#*~}" - print_record "$upstream_ip" "$UPSTREAM.pp.neo." - print_record "$downstream_ip" "$DOWNSTREAM.pp.neo." + ( + print_record "$("$IPTOOL" "$upstream_ip" 0)" "$UPSTREAM.pp.neo." + print_record "$("$IPTOOL" "$downstream_ip" 0)" "$DOWNSTREAM.pp.neo." + ) >> "$PP_TEMP" + elif [ "$TYPE" = "LO" ]; then + ip="${i/,32/}" + + print_record "$("$IPTOOL" "$ip" 0)" "$NAME.neo" >> "$LO_TEMP" fi done -) | sort -n >> dns/db.10.127 +) + +{ + echo -e "\n; Tunnel /30 Addresses" + sort -n < "$TUN30_TEMP" + echo -e "\n; Point to Point Addresses" + sort -n < "$PP_TEMP" + echo -e "\n; Loopback Addresses" + sort -n < "$LO_TEMP" +} >> dns/db.10.127 + +rm -f "$TUN30_TEMP" "$PP_TEMP" "$LO_TEMP"