X

Modify Hosts File In Windows and Linux

Modifying your hosts file will allow you to override the DNS for a domain, on that particular machine. This can be used to test your site without the test link, prior to going live with SSL, verify an alias site works prior to DNS changes, or for other DNS related reasons. This causes your local machine only to look directly at the IP specified.

Your hosts file will need to have two entries added that will contain the IP address you want the site to resolve to and the address. Adding the below two lines for example will point www.domain.com and domain.com to our current PHP5-ITK (“Refreshed” PHP5) cluster:

49.0.37.70 www.domain.com
49.0.37.70 domain.com

Below is how to locate and edit the hosts file on several OS platforms. Once the proper domain information is added you will save the file and your system will begin resolving to the specified IP. Once testing is finished these entries should be removed.

Contents:

  • Windows Vista and Windows 7
  • Windows NT/2000/XP
  • Linux

Windows Vista and Windows 7

Vista and Windows 7 use User Account Control (UAC) so Notepad must be run as Administrator.

  1. Click Start -> All Programs -> Accessories
  2. Right click Notepad and select Run as administrator
  3. Click Continue on the “Windows needs your permission” UAC window.
  4. When Notepad opens Click File -> Open
  5. In the filename field type C:\Windows\System32\Drivers\etc\hosts
  6. Click Open

Windows NT/2000/XP

  1. Click Start -> All Programs -> Accessories -> Notepad
  2. Click File -> Open
  3. In the filename field type C:\Windows\System32\Drivers\etc\hosts
  4. Click Open

Linux

  1. Open a terminal window
  2. Type sudo nano /etc/hosts (you can substitute any text editor)
  3. Enter your password

Comments

comments

Loading Likes...
Kazi S: XeonBD, Suite 2A, House 231, Road 06, Mohammadi Housing Limited, Mohammadpur, Dhaka 1207, Bangladesh Web: http://www.xeonbd.com | Blog: https://blog.xeonbd.com | Telephone: +88-02-8101735 | Fax: +88-02-8101736 Sales HotLine: +88 019 77XEONBD (936623)
Related Post
Leave a Comment

In order to give you the best experience, our website uses cookies.