DekGenius.com
I l@ve RuBoard Previous Section Next Section

2.18 Mapping Any Domain Name in a Zone to a Single IP Address

2.18.1 Problem

You want to map every domain name in a zone to a single IP address.

2.18.2 Solution

Add an A record to the zone attached to the wildcard domain name. For example:

*.foo.example.    IN    A    10.0.0.1

2.18.3 Discussion

Technically, this record doesn't map every domain name in the zone to 10.0.0.1. In fact, the wildcard domain name doesn't apply to domain names in the zone data file. Say you also had the domain name ns1.foo.example in the foo.example zone:

ns1.foo.example.    IN    A    192.168.0.1

The wildcard domain name wouldn't match queries for the address of ns1.foo.example, which is probably a good thing, since ns1.foo.example has a different address. The wildcard domain name wouldn't apply to domain names that own other types of records, either. For example, you might have this record in the zone:

text.foo.example.    IN    TXT    "Text comment"

Queries for the address of text.foo.example would return an empty answer, because text.foo.example has no addresses.

So what does the wildcard domain name apply to? Queries for domain names in the zone that don't appear in the zone data file, which means any domain name you can think of that ends in foo.example, doesn't appear in the foo.example zone data file, and isn't part of a delegated subdomain of foo.example.

Wildcard domain names can own other types of records, too. Take, for example, this CNAME record:

*.foo.example.    IN    CNAME    foo.example.

This creates aliases from any domain name in the zone without explicit records attachedto the domain name foo.example. So iif you leave out explicit records for www.foo.example, someone looking up www.foo.example would find that domain name is an alias for foo.example. Someone looking up zaphod.beeblebrox.foo.example would find that it, too, is an alias for foo.example -- assuming you didn't have any records attached to the domain name zaphod.beeblebrox.foo.example, that is. So you might think of a wildcard as a "default" domain name for a zone: any explicit domain name in the zone has only the records you give it, but the wildcard applies to every other domain name in the zone.

As the zaphod.beeblebrox.foo.example example suggests, wildcards can match more than one label. In fact, a wildcard matches zero or more labels. The wildcard domain name in the CNAME record wouldn't match just foo.example, though, since even at zero labels, *.foo.example has one more dot than foo.example.

2.18.4 See Also

"Wildcards" in Chapter 16 of DNS and BIND.

    I l@ve RuBoard Previous Section Next Section