MacOS – How to DNS resolve also subdomains to same host as the domain itself using wildcards

dnsmacosNetworkosx-server

We have a local DNS server running for development purposes. But it seems not to resolve subdomains to the same destination ip as the domain itself. As I figured out so far, we need to configure each subdomain itself or using a wildcard, so that the following mapping would be possible:

vhost1.example.com => example.com => 192.168.0.22
vhost2.example.com => example.com => 192.168.0.22
something.example.com => example.com => 192.168.0.22

Normally, in the internet, if you bought a domain this works just fine with subdomain (vhost) wildcard on the domain. Until now, there was no need for me to configure it on my owned domains. But locally on a Mac Server we have to configure it?!

After searching hours on the internet I found no solution that works for me. This post here does also not work for me.

We are using Mac OS X El Captian 10.11.6 on the server.

Edit: And yes, I cleared the cache after editing the DNS config by using the command dscacheutil -flushcache;killall -HUP mDNSResponder;say flushed as root user (sudo su)

Best Answer

This is how i usually do:

  1. Add primary domain example.com
  2. Add Machine Record example.com (inside domain example.com) with ip : 192.168.0.22
  3. Add alias vhost1.example.com -> example.com
  4. Add alias vhost2.example.com -> example.com

... etc you can add other records as usual

Related Question