At work we use OpenDNS and it has wrongly blocked irc.freenode.net for malware. How can I make sure that any request for *.freenode.net goes to and (Google's DNS).

I tried doing this by fiddling with resolv.conf on Ubuntu, but I wasn't able to get too far. Also, is there an easy way to do this for Mac and Windows systems (I have a few colleagues using those OSes and they'd like to use IRC as well).

  • 4
    Be careful - attempting to get around security controls can get one escorted out of some companies. Also, it is possible other DNS servers are blocked.
    – uSlackr
    May 23, 2012 at 17:09

6 Answers 6


Linux does not support the use of domain-specific DNS servers via resolv.conf. You could potentially work around this by running a caching nameserver (such as BIND or dnsmasq) locally and then configuring explicit forwarders for each domain.

Under OS X, this sort of setting is relatively easy using the scutil command. The common use case for this configuration is to forward DNS requests for a VPN connection to VPN-specific DNS servers, so you'll find this discussed often in concert with, e.g., OpenVPN. This document talks about the scutil command as does this, and a Google search for openvpn and scutil will yield more results.

I'm not sure about Windows. You could presumably use the local DNS server solution for all three platforms if you needed to.

  • 1
    Is this still true in the systemd-resolved world? (Yes I realize your answer is 7 years old)
    – Pointy
    May 1, 2019 at 20:21
  • 4
    @Pointy It seems recent versions of systemd-resolved can handle this: gist.github.com/brasey/…
    – corford
    Dec 6, 2019 at 20:46
  • Windows can do it using NRPT rules: Add-DnsClientNrptRule -Namespace "example.com" -NameServers "" Jan 25, 2020 at 18:07

This can't be done with the standard DNS resolution provided by *nix (and Windows AFAIK), you need your own DNS server to do this. On *nix dnsmasq is the best choice for this, and you can either run this on every workstation or run it on a server and configure all the workstations to use this.




  • 3
    This can absolutely be done using the standard DNS resolution provided by some operating systems. Just not by Linux.
    – larsks
    May 23, 2012 at 17:00
  • To control which interface to use I added the @vpn0 at the end of the DNS servers. This can be useful to use it only when a VPN is up.
    – Alex
    Apr 26, 2019 at 13:27

Under OS X you can use files like /etc/resolver/example.com with content:


to forward dns requests for *.example.com to


  • Does this apply for High Sierra ?
    – Tolsadus
    Oct 10, 2017 at 16:46
  • 2
    It still works on Mojave
    – byte255
    Feb 16, 2019 at 9:15

You can do it on Windows with PowerShell:

Add-DnsClientNrptRule -Namespace "pqr.com" -NameServers ""

Reference: https://docs.microsoft.com/en-us/powershell/module/dnsclient/add-dnsclientnrptrule?view=win10-ps

  • +1 and thanks a lot. This saved my day.
    – Binarus
    Oct 2, 2020 at 15:13

It's possible to use firejail --dns option for this. For example:

firejail --dns= firefox

This way dns server can be set per application instead of per domain. So it might be a better solution in some circumstances.


I did this on Fedora by installing a local DNS server.

first install bind:

sudo dnf install bind

step 1: append a line to /etc/named.conf (as root):

include "/etc/named/freenode.net.conf";

step 2: create the zone file /etc/named/freenode.net.conf (as root):

zone "freenode.net" {
    type forward;
    forwarders {; };

now restart named:

sudo service named restart

now reconfigure your lan settings to use as the DNS server, rather than the DCHP-allocated hosts.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.