Skip to content

Instantly share code, notes, and snippets.

Created June 30, 2023 12:37
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?

Wildcard DNS on Mac

June 30, 2023 at 5:12:48 AM


You are ChatGPT, a large language model trained by OpenAI, based on the GPT-4 architecture. You are chatting with the user via the ChatGPT iOS app. This means most of the time your lines should be a sentence or two, unless the user's request requires reasoning or long-form outputs. Never use emojis, unless explicitly asked to. Knowledge cutoff: 2021-09 Current date: 2023-06-30


There are a few ways you could do this. Here are two common methods:

  1. Dnsmasq: This is a lightweight network infrastructure utility for providing DNS, DHCP, router advertisements, and network boot. You can install it with Homebrew by running brew install dnsmasq. Then, you'll need to configure it to redirect all .localdev.local queries to This can usually be done by adding a line like address=/.localdev.local/ to the dnsmasq configuration file.

  2. Local DNS Server: You can set up a local DNS server, like BIND, that has a wildcard record for .localdev.local to point to This is more complex and probably overkill for your needs, but it's more flexible and might be useful if you're doing more complicated network simulations.

Please note that after making these changes, you'll likely need to flush your DNS cache for the changes to take effect. On a Mac, you can do this by running sudo killall -HUP mDNSResponder in Terminal.


Sure, here is a step-by-step guide on how to install and configure Dnsmasq for your requirement on a Mac:

  1. Install Homebrew if you haven't done that yet. Open Terminal and paste the following command:

    /bin/bash -c "$(curl -fsSL"
  2. Install Dnsmasq using Homebrew by running the following command:

    brew install dnsmasq
  3. Configure Dnsmasq. First, copy the default configuration file to the right place:

    cp $(brew list dnsmasq | grep /dnsmasq.conf.example$) /usr/local/etc/dnsmasq.conf
  4. Edit the Dnsmasq configuration file. You can use a text editor like nano or vim. Here's how you'd do it with nano:

    nano /usr/local/etc/dnsmasq.conf

    Once inside the configuration file, add the following line:


    Press ctrl+X to exit, and confirm with Y to save the changes.

  5. Start Dnsmasq. You can do this with the following command:

    sudo brew services start dnsmasq

    This will also set Dnsmasq to start on boot.

  6. Add Dnsmasq as a resolver for .localdev.local domain. macOS needs to know that it should use Dnsmasq for .localdev.local domains. Create a resolver file for it:

    sudo mkdir -v /etc/resolver
    sudo bash -c 'echo "nameserver" > /etc/resolver/localdev.local'
  7. Test your setup. You can do this by using the dig command to query a .localdev.local domain and checking that the response comes from Dnsmasq. Here's how:

    dig test.localdev.local @

    You should see an ANSWER SECTION in the output with test.localdev.local pointing to

  8. Flush your DNS cache. You can do this by running:

    sudo killall -HUP mDNSResponder

That should be it! All .localdev.local queries on your machine should now resolve to

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment