- To edit to your hosts file start by opening your terminal.
- Then run the following command:
sudo nano /etc/hosts
- When you are prompted for your password enter it.
- Nano is a commandline text editor and it will open up your hosts file.
- Add your hosts entries to the file, it should look something like this:
##
# Host Database
#
# localhost is used to configure the loopback interface
# when the system is booting. Do not change this entry.
##
127.0.0.1 localhost
255.255.255.255 broadcasthost
::1 localhost
fe80::1%lo0 localhost
10.10.10.10 new-host-1.domain.tld new-host-1
192.168.1.50 new-host-2.domain.tld new-host-2
- Save the file by pressing
Ctrl
+o
and then exit nano by pressingCtrl
+x
. - Clear your DNS cache by entering the following command into your terminal:
dscacheutil -flushcache
- Finally ping each new host and verify that it resolves to the IP address that you defined in your hosts file:
ping new-host-1.domain.tld