Modify your hosts file
Modifying your hosts file enables you to override the domain name system
(DNS) for a domain on a specific machine. DNS management
is useful when you want to test your site without the test link prior to going live with SSL,
verify that an alias site works prior to DNS changes, and for other DNS-related reasons.
For information about changing your DNS settings, see Changing DNS settings on Linux.
Modifying your hosts file causes your local machine to look directly at
the Internet Protocol (IP) address that you specify. Rackspace offers
managed hosting solutions to assist with
the handling of these resources.
Modifying the hosts file involves adding two entries to it. Each entry
contains the IP address to which you want the site to resolve and a version of
the Internet address. For example, add the following two entries points,
www.domain.com and domain.com, to Rackspace's current refreshed PHP5
(PHP5-ITK) cluster:
64.49.219.194 www.domain.com
64.49.219.194 domain.com
This article provides instructions for locating and editing the hosts file
on the following operating systems:
- Microsoft® Windows® 10, Windows 8, Windows 7, and
Windows Vista™ - Microsoft Windows NT™, Windows 2000, and Windows XP
- Linux®
- MacOS® X versions 10.0 through 10.1.5
- MacOS X versions 10.6 through 10.12
After you add the domain information and save the file, your system begins to
resolve to the IP address that you specified. When testing is complete, remove
these entries.
Windows
If you are using a Microsoft operating system
like Windows 10, Windows 8, Windows 7, and Windows Vista you must run Microsoft Notepad
as an administrator.
Windows 10 and Windows 8
Use the following instructions if you're running Windows 10 or Windows 8:
-
Press the Windows key.
-
Type Notepad in the search field.
-
In the search results, right-click Notepad and select Run as
administrator. -
From Notepad, open the following file:
c:\Windows\System32\Drivers\etc\hosts
-
Make the necessary changes to the file.
-
Select File > Save to save your changes.
Windows 7 and Windows Vista
Use the following instructions if you're running Windows 7 or Windows Vista:
-
Select Start > All Programs > Accessories.
-
Right-click Notepad and select Run as administrator.
The Windows needs your permission UAC window appears.
-
Click Continue to grant permission.
Notepad opens.
-
In Notepad, select File > Open.
-
In the File name field, enter the following path:
C:\Windows\System32\Drivers\etc\hosts
-
Select Open.
-
Make the necessary changes to the file.
-
Select File > Save to save your changes.
Windows NT, Windows 2000, and Windows XP
Use the following instructions if you're running Windows NT, Windows 2000, or
Windows XP:
- Select Start > All Programs > Accessories > Notepad.
- Select File > Open.
- In the File name field, enter
C:\Windows\System32\Drivers\etc\hosts. - Select Open.
- Make the necessary changes to the file.
- Select File > Save to save your changes.
Linux
Use the following instructions if you're running Linux:
-
Open a Terminal window.
-
Enter the following command to open the hosts file in a text editor:
sudo nano /etc/hosts
-
Enter your domain user password.
-
Make the necessary changes to the file.
-
Press Control-X.
-
When you are asked if you want to save your changes, enter y.
MacOS X versions 10.0 through 10.12
This section provides instructions for modifying your hosts file if you are
running MacOS X 10.0 through 10.12.
MacOS X 10.0 through 10.1.5
Use the following instructions if you're running MacOS X 10.0 through 10.1.5:
-
Open /Applications/Utilities/NetInfo Manager.
-
To enable editing of the Network Information database (NetInfo), click the
padlock icon in the lower-left corner of the window. -
Enter your domain user password and select OK.
-
In the second column of the browser view, select the node named
machines. -
In the third column, select the entry named
localhost
. -
From the Edit menu, select Duplicate.
A confirmation alert appears.
-
Click Duplicate.
A new entry named
localhost copy
appears and its properties are
displayed below the browser view. -
Double-click the value of the
ip_address
property and enter the IP
address of the other computer. -
Double-click the value of the
name
property and enter the host name that
you want use for the other computer. -
Click the
serves
property and select Delete from the Edit menu. -
From the File menu, select Save.
A confirmation alert appears.
-
Click Update this copy.
-
Repeat steps 6 through 12 for each additional host entry that you want to
add. -
From the NetInfo Manager menu, select Quit.
You do not need to restart the computer.
MacOS X 10.6 through 10.12
Use the following instructions if you're running MacOS X 10.6 through 10.12:
-
On your computer, select Applications > Utilities > Terminal to open a
Terminal window. -
Enter the following command in the Terminal window to open the hosts
file:sudo nano /private/etc/hosts
-
When you are prompted, enter your domain user password.
-
Edit the hosts file.
The file contains comments (lines that begin with the
#
symbol) and some
default host name mappings (for example,127.0.0.1 – local host
). Add
your new mappings after the default mappings. -
To save the hosts file, press Control+X.
-
When you are asked if you want to save your changes, enter y.
-
To force your changes to take effect, flush the DNS cache by entering the
following command:dscacheutil -flushcache
Updated about 1 year ago