Is it possible to do something like this? Or any equivulent? in a DNS server.
([0-9]{2}).mydomain.com. IN CNAME www$1.other-domain.com.
|
Is it possible to do something like this? Or any equivulent? in a DNS server. ([0-9]{2}).mydomain.com. IN CNAME www$1.other-domain.com.
| |||||||||||||
feedback
|
This question came from our site for professional and enthusiast programmers.
|
DNS doesn't. But the most popular $GENERATE 1-99 www$ CNAME www$.other-domain.com. Beware that this is incompatible with other DNS server software. | |||
|
feedback
|
|
The DNS protocol does not support regular expressions. This said, there is no reason why a name server should not have the capability to evaluate regular expressions internally and serve standard DNS answers. It won't work with the standard zone format as defined in RFC 1035 section 5 and RFC 1034 section 3.6.1 and I'm not aware of any name server actually implementing support for regular expressions, but basically it is possible. | |||
|
feedback
|
|
Although regex handling could be written into a DNS server it would be a bad idea to do so. Any DNS server modified to handle regex expansion is going to have trouble co-existing with the rest of the world. Zone transfers to "standard" servers would either be incomplete, incorrect or absolutely massive, as each permutation would have to be sent as a separate record. Depending on the regex that could result in an almost infinite number of possible records, which is clearly impractical because the transfer may never complete, leaving systems out of sync. Of course if transfers were only ever to happen between modified servers this might be OK but the universe has a tendency to destroy such simplicity. | |||||||
feedback
|
|
As jrockway suggested, if you can afford to roll your own nameserver, you have full control over the replies you give. In that case, you could reply with the CNAME record you want, based on the query. I don't know how much DNS traffic you expect to have, how mission critical your web site is, but you could try a DNS server implemented in Perl, using the Net::DNS::Nameserver module. Alternatively, since your regex is just a shortcut for 100 DNS resource records, you could just run BIND, and have a script generate the zone file you want. Or, just use your registrar's tools to create the 100 CNAME records. | |||
|
feedback
|
|
No. But you can have a wildcard:
which won't quite do what you want, but maybe you can do some server-side validation to ensure that the hostname is valid? Won't help with re-writing to a different | |||||
feedback
|
|
No regex, just wildcard domain names, e.g. | |||
|
feedback
|
|
You can't do this with standard DNS software. It is possible if you use a custom DNS server which recognises that particular pattern and then dynamically synthesises the correct response. It would actually be trivial for example using my evldns server framework. If you know 'C' it should take less than an hour to implement. Note however that all authoritative DNS servers for the domain would need to have this feature. Whilst a wildcard record can be happily transferred from primary to secondary servers using | |||
|
feedback
|