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
apt-get install bind9
On CentOS/RHEL
yum install bind9
Create a Catch-All zone file.
vi /etc/bind/catch-all.zone
Add following content to the file
@ 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
vi /etc/bind/named.conf.local
On Debian
vi /etc/bind/named.conf
At the end of the file, add
zone "." IN {
type master;
file "/etc/bind/catch-all.zone";
};
Verify there is no error.
named-checkconf
Restart bind
systemctl restart bind9
Now verify Catch all DNS zone works with
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
IN MX 0 mx1.mail-server.com.
IN MX 5 mx2.mail-server.com.
See bind