Sometime, you’d want to use the Hosts file instead of just letting DNS do its thing. For example, you are testing your sites before public it. Or you want to move site from old hosting to new hosting but dont want your site down. That’s why you can use the hosts file instead: Enter the server’s IP address or sub-domain and when you use that domain name, your Mac will go to that device instead. In this tutorial, i want to access google.com but it will show content from yahoo server instead of Google server. Let’s try edit host file MAC.
How to edit the Hosts file MAC
In this tutorial, i will use Terminal application found in your Mac’s Utilities folder to edit hosts file. The hosts file is locate at /etc/hosts on your MAC computer.
To open Terminal on your MAC, follow these step:
Step 1: Click on the Launchpad icon at the bottom bar on your MAC (red circle in below picture) and then click into Other:
Step 2: On Other screen, click into Terminal icon:
Step 3: Terminal Window will open, type: sudo nano /etc/hosts and then hit Enter (Return) on your keyboard. It will ask for permission, please enter your password and press Enter (return) to continue:
Step 4: Screen with /etc/hosts contents will show up. Move your mouse to the end of contents and enter your destination IP, and domain name you want to move as picture below (in green circle) – you can type the IP address, hit tab, then type the domain name. In this example, i will move google.com to 22.214.171.124, that’s a Yahoo server IP. Each move to one line. Press Enter (Return) to break line.
Step 5: After you’ve done, hold down the Control and O keys to save the file, then control and X to exit.
Step 6: It will back to Terminal screen. Type sudo killall -HUP mDNSResponder and then press Enter (Return). This command will flush your Mac’s DNS cache.
Step 7: Open Safari and then type your domain (in my case is Google.com) and then enter. You should see the contents of new IP server.
Other Posts you may be interested in:
- Giáng sinh sớm với khuyến mại 75% OFF từ Hostgator
- Domains – Namecheap domains
- Tình xưa nghĩa cũ 2 – Jimmy Nguyễn
- Chặn dải IP Việt Nam truy cập bằng htaccess hoặc nginx
- Tăng tốc độ Copy/Move files với TeraCopy 2.3
- Ất Mùi 2015 – việc nên làm và không nên làm
- How to fix Error 0x8007045b
Last updated on March 31st, 2020 at 05:56 am