BIND IPv6 $GENERATE: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
(3 intermediate revisions by the same user not shown) | |||
Line 3: | Line 3: | ||
=generate-forward-ipv6.sh= | =generate-forward-ipv6.sh= | ||
<pre> | |||
#!/bin/sh | #!/bin/sh | ||
# generate these lines: | # generate 250 of these lines: | ||
# ip20-042 IN AAAA 2001:dead:beef:14::2a | # ip20-042 IN AAAA 2001:dead:beef:14::2a | ||
# where 20(0x14) is the vlanid and 42(0x2a) is the host part | # where 20(0x14) is the vlanid and 42(0x2a) is the host part | ||
Line 14: | Line 14: | ||
vlanid=$1 | vlanid=$1 | ||
counter=1 | counter=1 | ||
while [ $counter -le | while [ $counter -le 250 ]; do | ||
printf "ip$vlanid-%03d\tIN\tAAAA\t2001: | printf "ip$vlanid-%03d\tIN\tAAAA\t2001:dead:beef:%x::%x\n" $counter $vlanid $counter; | ||
counter=`expr $counter + 1` | counter=`expr $counter + 1` | ||
done | done | ||
</pre> | |||
=generate-reverse-ipv6.sh= | |||
<pre> | |||
#!/bin/sh | |||
# generate these lines: | |||
# $ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.1.0.0.f.e.e.b.d.a.e.d.1.0.0.2 PTR ipv6.example.com. | |||
# 1.0 PTR ip20-042.example.com. | |||
if [ -z $1 ]; then | |||
echo "usage: $0 <vlanid>" | |||
exit | |||
fi | |||
vlanid=$1 | |||
reversedottedhexvlan="`printf "%04x\n" $vlanid | rev | sed -e 's/^./&./' | sed -e 's/^.../&./' | sed -e 's/^...../&./'`" | |||
echo "\$ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.$reversedottedhexvlan.f.e.e.b.d.a.e.d.1.0.0.2.ip6.arpa." | |||
counter=1 | |||
while [ $counter -le 250 ]; do | |||
reversedottedhostid="`printf "%02x\n" $counter | rev | sed -e 's/^./&./'`" | |||
printf "$reversedottedhostid PTR ip$vlanid-%03d.example.com.\n" $counter; | |||
counter=`expr $counter + 1` | |||
done | |||
</pre> |
Latest revision as of 14:17, 21 March 2012
There is no $GENERATE command available on IPv6, therefore you must specify every forward and reverse entry in bind manually. You could however use the $INCLUDE statement to include a range you have generated with a script. I will post a script here to generate IPv6 forward and reverse files you can include in bind.
generate-forward-ipv6.sh
#!/bin/sh # generate 250 of these lines: # ip20-042 IN AAAA 2001:dead:beef:14::2a # where 20(0x14) is the vlanid and 42(0x2a) is the host part if [ -z $1 ]; then echo "usage: $0 <vlanid>" exit fi vlanid=$1 counter=1 while [ $counter -le 250 ]; do printf "ip$vlanid-%03d\tIN\tAAAA\t2001:dead:beef:%x::%x\n" $counter $vlanid $counter; counter=`expr $counter + 1` done
generate-reverse-ipv6.sh
#!/bin/sh # generate these lines: # $ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.4.1.0.0.f.e.e.b.d.a.e.d.1.0.0.2 PTR ipv6.example.com. # 1.0 PTR ip20-042.example.com. if [ -z $1 ]; then echo "usage: $0 <vlanid>" exit fi vlanid=$1 reversedottedhexvlan="`printf "%04x\n" $vlanid | rev | sed -e 's/^./&./' | sed -e 's/^.../&./' | sed -e 's/^...../&./'`" echo "\$ORIGIN 0.0.0.0.0.0.0.0.0.0.0.0.0.0.$reversedottedhexvlan.f.e.e.b.d.a.e.d.1.0.0.2.ip6.arpa." counter=1 while [ $counter -le 250 ]; do reversedottedhostid="`printf "%02x\n" $counter | rev | sed -e 's/^./&./'`" printf "$reversedottedhostid PTR ip$vlanid-%03d.example.com.\n" $counter; counter=`expr $counter + 1` done