Skip to content

Instantly share code, notes, and snippets.

@codenathan
Created September 6, 2023 21:25
Show Gist options
  • Save codenathan/ba92f25b30ee60cf5ae56e92aa4f433d to your computer and use it in GitHub Desktop.
Save codenathan/ba92f25b30ee60cf5ae56e92aa4f433d to your computer and use it in GitHub Desktop.
CUSTOM Dnsmasq Configuration for MAC

Custom Dnsmsq Config on MAC

Add Additional Config File

Open the dnsmasq configuration file by running the following command in your terminal:

sudo nano /usr/local/etc/dnsmasq.conf

Add the following line to include your custom configuration file (replace /Users/codenathan/dnsmasq-snathan.conf with the actual path to your custom configuration file):

conf-file=/Users/codenathan/dnsmasq-snathan.conf

Within this file, specify the domains you want to send to 127.0.0.1. For example:

address=/club/127.0.0.1
address=/cx/127.0.0.1
address=/cz/127.0.0.1
address=/fun/127.0.0.1
address=/icu/127.0.0.1
listen-address=127.0.0.1

You'll need to create additional resolvers for each of these domains. Follow the instructions below.

Additional Resolver

macOS allows you to configure additional resolvers by creating configuration files in the /etc/resolver/ directory.

If this directory doesn't exist, create it by running the following command:

sudo mkdir -p /etc/resolver

Navigate to the newly created directory:

cd /etc/resolver

For each domain extension (e.g., xyz), create a new configuration file with that extension as the filename (e.g., /etc/resolver/xyz).

nameserver 127.0.0.1

Now, your custom dnsmasq configuration is set up to redirect specified domains to 127.0.0.1, and you have created additional resolvers for each of these domains. Make sure your dnsmasq service is running to apply these changes effectively.

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