Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I would like to have for each private IP a mapping like this:

ip-192-168-0-1.domain IN A 192.168.0.1

I am using bind9. Is there any way to use a regex to do this? I know that bind supports wildcard records but I was unable to find any example with regular expressions.

Do I have to add a record for each IP?

share|improve this question
add comment

1 Answer 1

up vote 6 down vote accepted

You can use the $GENERATE statement to define multiple records which only differ by an iterator. For example:

$GENERATE 1-255 ip-192-168-0-$.domain A 192.168.0.$

Edit: It doesn't seem possible to nest $GENERATE statements, so if you need to build records for more than a /24 you'll need a separate line for each /24. You can of course use a script to generate this:

for I in `seq 0 255`; do
    echo "\$GENERATE 1-255 ip-192-168-$I-\$.domain A 192.168.$I.\$"
done >> myzone
share|improve this answer
    
How can I use this to map 192.168.0.0/16? –  Robert Dolca Feb 15 '13 at 6:38
    
I'm sure from this information you can find this in the manual and construct the appropriate line your your situation. –  mdpc Feb 15 '13 at 7:25
    
I read the manual before commenting but I found this 'can be used to easily generate the sets of records required to support sub /24 reverse delegations' –  Robert Dolca Feb 15 '13 at 7:43
    
@RobertDolca Edited. –  mgorven Feb 15 '13 at 17:05
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.