Introduction
If you want to be able to change the resolution of domains to Its for a specific local machine, you will want to be able to change your hosts file.
Your hosts file allows you to tell a specific computer to resolve a domain to a specific IP address, which can be handy for developers, personal networking setups and a range of other advanced tasks, including blocking connections to certain domains.
Tools
Parts
No parts specified.
-
-
You can find Terminal in Applications or Launchpad, usually under Utilities
-
-
-
This will change the directory to where we need to issue the next command
-
-
-
The command sudo gives you full administrator access to your machine, and so should be used very carefully - as such, it will ask for your administrator password
-
Nano is a command line text editor, and so will allow you to edit your hosts file
-
-
-
You can add new entries to the end of the file
-
Add the IP address you want to resolve to first, and then place the domain name you want to resolve to that IP address afterwards
-
e.g. 1.2.3.4 domain.com
-
Existing entries in the file can be used as a template, but don't change them!
-
If you want to block a domain name from working, you can direct it to a false IP address such as 0.0.0.0
-
e.g. 0.0.0.0 blocked.com
-
Once you are finished editing, press Ctrl + X on your keyboard to exit, and then press Y when asked whether you want to Save or 'Write Out' (another term for saving)
-
-
-
In most instances, after you save your Hosts file, it should work instantly. However, sometimes you may need to flush your DNS cache before it starts to take effect
-
To do this, enter in Terminal 'sudo killall -HUP mDNSResponder' and press return
-
Remember to exclude the quotation marks
-