Quantcast
Channel: Digitivity » HowTo
Viewing all articles
Browse latest Browse all 10

How to Manually Add Hosts in Windows, Linux, and OS/X

$
0
0

Normally when you want to access a server on the Internet, you specify its name, like “www.google.com”. What actually happens behind the scenes is that your computer finds out the “IP address” of where you want to go. The IP address is like the “telephone number” of a server. The IP address for Google is 64.233.181.104 .

Go ahead and try it, you’ll end up at Google.

If the IP address is a “telephone number”, then the name (like the name you enter for a number in your cell phone) is called a host name. “Host” is just another word for server or computer.

Anyway, normally all of this works automagically, and you don’t even notice it. Once in a while it may not, for example, in a home network, thus forcing you to type in numbers instead of names.

There’s a way to set hostnames to IP addresses manually.

The hosts file

It’s called a “hosts” file, and it works generally the same on Windows, Linux/Unix, and Mac OS/X.

The hosts file is a list of IP addresses followed by hostnames, separated by a space, like this:

64.233.181.104 www.google.com
192.168.0.4 myhomecomputer

By the way, there’s a neat little trick you can use to block ads by setting the address of adservers, like Double Click’s, to your local computer:

127.0.0.1 ad.doubleclick.net

Note: 127.0.0.1 is a special address that always refers to your own computer.

The hosts file’s location differs from system to system:

Setting hosts/IP address on Windows

On Windows 95, 98, and ME, the host file is at c:\windows\hosts .

On Windows NT, 2000, XP, Vista, and 7, it’s at C:\windows\system32\drivers\etc\hosts .

View your hosts file

You can modify it with Notepad (Accessories menu).

Setting hosts/IP address on Mac OS/X

In Mac OS X 10.2 or later, hosts is at /private/etc/hosts

To edit it, type this into a terminal (Applications > Utilities > Terminal)

sudo nano

Enter your own password if prompted, add a hostname entry, then press Ctrl+x to exit the editor, and save the modified file by pressing “y”.

You have to then flush the DNS cache (OS/X doesn’t do that automatically):

sudo dscacheutil -flushcache

More info: http://support.apple.com/kb/TA27291
http://www.leftcolumn.net/2009/07/04/adding-an-entry-to-etchosts-on-os-x/

Setting hosts/IP address on Linux/Ubuntu/Unix

On Linux and all other Unixes, hosts is at
/etc/hosts .

View your hosts file

You have to have either sudo or root privileges to edit it.

Related posts:

  1. Microsoft (Finally) Wants You to Ditch IE6
  2. My Windows XP Gets Virus Infected
  3. How to Install Miro Podcast Viewer on Windows

Viewing all articles
Browse latest Browse all 10

Latest Images

Trending Articles





Latest Images