If you VPN to work from home (or even VPN to home from work ;-)), you may have issues resolving hostnames. A good way to solve this issue is to use the /etc/resolver
folder. If you have DNS set up, you can assign specific domains to be resolved by specific name servers. To implement, simply create a file in the /etc/resolver
folder with the same name as the domain you want to configure:
# cd /etc/resolver # sudo touch mydomain.com # sudo touch myotherdomain.com # ls -la drwxr-xr-x 5 root wheel 170 Sep 13 10:17 . drwxr-xr-x 101 root wheel 3434 Jan 25 17:10 .. -rw-r--r-- 1 root wheel 45 Jan 30 12:49 mydomain.com -rw-r--r-- 1 root wheel 72 Jan 30 10:45 myotherdomain.com
Then, within each file, include the DNS servers you wish to resolve against that domain:
# sudo sh -c 'echo "nameserver 10.0.0.1" >> mydomain.com' # sudo sh -c 'echo "nameserver 192.168.0.1" >> myotherdomain.com'
NOTE: The sudo sh -c '<cmd>'
is necessary to run the redirection with the correct privileges. See this thread.