Wildcard DNS zone in bind
Wildcard DNS zone will act as authoritative DNS for any domain name. This is useful when you have a service like domain name parking service, where customers will change name servers of their domain name to your private label name servers. You need all thse domains get resolved to a specific IP address with out manually configuring DNS zone for each of the domain name.
Install Bind DNS server.
On Ubuntu/Debian
1 |
apt-get install bind9 |
On CentOS/RHEL
1 |
yum install bind9 |
Create a Catch-All zone file.
1 |
vi /etc/bind/catch-all.zone |
Add following content to the file
1 2 3 |
@ IN SOA ns1.yourdomain.com. hostmaster.yourdomain.com. ( 1 3h 1h 1w 1d ) IN NS YOUR_IP_ADDR_HERE * IN A YOUR_IP_ADDR_HERE |
In above, replace
YOUR_IP_ADDR_HERE = IP you need all domains resolve to.
yourdomain.com = replace with your private label name server domain.
To make this zone active, you need to add it to named.conf, edit
On CentOS
1 |
vi /etc/bind/named.conf.local |
On Debian
1 |
vi /etc/bind/named.conf |
At the end of the file, add
1 2 3 4 |
zone "." IN { type master; file "/etc/bind/catch-all.zone"; }; |
Verify there is no error.
1 |
named-checkconf |
Restart bind
1 |
systemctl restart bind9 |
Now verify Catch all DNS zone works with
1 |
nslookup serverok.in YOUR_DNS_SERVER_IP_HERE |
It should resolve to the IP address specified in DNS zone file catch-all.zone. In above example, i used serverok.in for testing, you can use any domain, that should resolve to the IP address.
If you need to set MX rcord for the domains, you can add following to end of catch-all.zone file
1 2 |
IN MX 0 mx1.mail-server.com. IN MX 5 mx2.mail-server.com. |
See bind