Recently I built up a local DNS server on my mac, and I want every DNS query go through that server rather than the distributed DNS address( from my router.

I think redirecting the to would be the best solution.

But after a search on google, I never met one person who have a similar question. Other answer were vague or wrong. Now I know I should use pfctl but I failed doing it several times.

Can someone please tell me how to redirect a LAN port to a local port? Thanks!

  • There are two conflicting answers here, assuming two conflicting scenarios. Do you want this server for all computers, or just for that one Mac?
    – Tetsujin
    Commented May 28, 2022 at 6:54
  • @Tetsujin Thinking about it, I suspect it is the use (in the question) of the word "redirect" which is key. I have answered as if the intention was "changing" the DNS server to be used by the Mac in question. You have answered as if it is changing the DNS server to be used by every computer on the network. I hope Simon will clarify what is intended.
    – Gilby
    Commented May 29, 2022 at 10:57

2 Answers 2


As you say, your router is acting as a DHCP server and the DHCP data includes setting your DNS server to the router (in your case

My router gives out as the DNS server, but I have overridden that to use

enter image description here

You can set the DNS Server in the Advanced... options. Use the + and - to add and remove DNs addresses, so that you get this:

enter image description here

Then you will discover if you have configured your DNS server correctly!!

I don't why or how you are building your DNS server, but my use case is to a) hide DNS traffic from my service provider and b) to block on trackers. Rather than building a DNS server or resolver from scratch, I have used DNSCrypt Proxy and more recently Adguard Home.

In the above I have, like the questioner, used the term "DNS Server" even though that should strictly be "DNS Resolver".


You cannot redirect to because that's internet shorthand for "me".
You need to set your DHCP server to broadcast the correct DNS IP Address, at your router - that's where all computers will look for an authoritative answer as to where DNS is.

Note if your own server isn't correctly updating from a more authoritative server outside your LAN, you may get failures.

  • No, you can set your DNS server to overriding what is given out by the DHCP server.
    – Gilby
    Commented May 27, 2022 at 22:21
  • If you change that in the DHCP server it will affect all the other computers on the LAN, not just the Mac.
    – Barmar
    Commented May 27, 2022 at 23:36

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .