May 24, 2010 | HowTo

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.


If you liked this article

If you liked this article, don’t forget to subscribe for updates!

Subscribe to New Articles by RSS or E-mail

Get updates by RSS (What’s RSS?)

Subscribe by email:

Follow me on Twitter

Top Incoming Search Terms

add dreamhost hostname os x add host entry linux add host to terminal osx add ip addresses to /private/etc/hosts mac add ips hosts osx adding host addresses osx apple ip youtube terminal hosts cache:http://digitivity.org/964/how-to-manually-add-etc-host-ip-address-in-windows-linux-and-osx commentluv enabled comments in /etc/hosts linux finding /etc/hosts macos manually hosts on linux similar to hosts file on windows how do i manually add a ip address how do you check what is the dns for 64.233.181.104 how to add hostname in terminal how to check the dns for 64.233.181.104 how to create ip address manually how to manually add a host ip address in windows 7 how to manually add hosts how to manually add hosts to windows 7 how to manually set ip address in hosts file of windows operating system how to manually specify dns for mail how-to add hostname in linux http://digitivity.org/964/how-to-manually-add-etc-host-ip-address-in-windows-linux-and-osx http://digitivity.org/964/how-to-manually-add-etc-host-ip-address-in-windows-linux-and-osx#comment-4927 ip address manually linunx hostnames os x linux add hosts linux facebok hosts linux howto add hosts linux ip address windows hosts locate lucid add to hosts lucid linux hostname etc/host mac "os x" howto edit etc hosts mac os x manually specify the ip of a hostname manual add host to dns manual add ip and host file manuall setting host address on os x manually add host manually add host ip ubuntu manually add windows hosts manually adding an entry into my hosts file for windows 7 os x add hostnames osx dns manual setting terminal sudo nano add hosts ubuntu manually add domain name youtube host file on linux youtube ip etc hosts mac os x

Related posts:

  1. Frozen Bubble: A Fun and Addictive Marbles Game for Windows, Linux, and Mac Frozen Bubble is a fun game for wasting time while...
  2. How to Add an E-mail to a Gravatar Account Your Gravatar account can have more than one e-mail associated...
  3. How to Install Google Skipfish on Ubuntu Linux Skipfish is a new security scanning tool from Google that...
  4. Install Free Software on Mac OS/X with Darwin Ports In case you didn't know, Mac OS/X is a complete...
  5. Keep Notes and Stay Organized with Zim Desktop Wiki Someone complemented me the other day that I'm pretty organized....

Explore related content: , , , , , ,

46 Responses to “How to Manually Add Hosts in Windows, Linux, and OS/X”

  1. Really thanks for sharing this information.

  2. Maxine says:

    Thanks for the info on Windows 7. I just switched over and could not find it or anywhere online that would let me know it was in the same location as my old XP box.

  3. How to YoYo says:

    Step-by-step info really helps us kinda impaired folks thanks.

  4. Keith says:

    It is well worth taking a quick look through your hosts file and seeing what is there. Many spyware / antivirus software programs use it to prevent you from going to bad sites, but there are also viruses that will redirect you from favourite search engines to a bad site through a hack on this file. So, knowing where it is and what it looks like is very useful.

    Thanks!
    Keith´s last blog ..The 3 Month Challenge My ComLuv Profile

  5. Kirpykla says:

    It work. Thank you.

  6. Matthew says:

    This is also helpful when you’re developing websites and you want to use the full domain name. Just set the domain to a local IP in your hosts file and you should be able to view the local copy instead of the live one.
    Matthew´s last blog ..Binero My ComLuv Profile

  7. Sports News says:

    An informative post. Thanks for sharing. Good research work for all three operating systems.

  8. andi says:

    wow its awsome blog, i learn so much by reading your blog especially this article, thanks for share
    andi´s last blog ..Gambar Modifikasi Nissan 2003 Type 350Z My ComLuv Profile

  9. jimmy41687 says:

    Well most of the people in the it field already knew this the name helps normal user to use intrenet more.
    jimmy41687´s last blog ..Make Money Online My ComLuv Profile

  10. lolzza.com says:

    Great step by step tutorial.

  11. linux is truly a very complicated os for such beginners…

  12. good tutorial
    is there a tool for speed up this process in windows?
    it really takes me lot of time to modify this file
    Giochi Super Mario´s last blog ..Mario vs Boo My ComLuv Profile

  13. Thanks for sharing is very helpful for me.God bless you.
    videos cristianos´s last blog ..¡Tenga cuidado- My ComLuv Profile

  14. Thanks for sharing this, I recently switched to Windows 7 and couldn’t find how to do this, after finding your blog post here you’ve just given me the information I needed.

    Well structured and informative, thanks again.
    Personalised Wedding Banners´s last blog ..Personalized Birthday Banner My ComLuv Profile

  15. great article, you tols us the actuals that happen when we search for some name please do tell us what happens when we search in google or yaaho what these spider do that will be an add on for our dictionary

  16. Mats says:

    I did not get this to work before reading this. Now I found how to do it. Thanks

  17. This is also helpful when you’re developing websites and you want to use the full domain name.I recently switched to Windows 7 and couldn’t find how to do this, after finding your blog post here you’ve just given me the information I needed.Thanks for sharing this.

  18. Thanks for such informative post. i was looking for it from last 2-3 months. You make my task easy, I’m so happy to have your blog. Thanks a lot, keep on like that. From now I’m a regular user of your blog.

  19. Windows LSP says:

    thank you for this very informative post. this is so helpful.

  20. Hi,

    This is very good info. Can I add one more thing?
    You can give a servermultiple names in your host file.
    For example:

    132.10.10.1 aamyserveraa.com bbmyserverbb.com

    So when you ping/call aamyserveraa.com or bbmyserverbb.com both point to the same server.

    VMS commands:
    To add a host entry
    $ucx set host SERVER-B /ADDRESS=132.10.10.1

    To remove a host entry
    $ucx set nohost SERVER-A /noconfirm

    To check your host entires
    $ucx sho host

  21. Great Article…now I clear my problem with Setting hosts on Linux…Thanks
    Golf Swing Mechanics´s last blog ..5 Fundamentals for Mechanics Golf Swing My ComLuv Profile

  22. Food Hampers says:

    Been looking everywhere for info on this so I can switchover. Alot easier to do than I thought it would be. Thanks for the info.

  23. thanks for sharing.. i like reading this posting..
    bestregards

  24. Eugenia Ayot says:

    I was searching for this information because I needed to make some changes here at work, and found your site through google. Thanks for giving step-by-step instructions. It saved me calling the IT department, which here is a good thing. Thanks again!

  25. used tires says:

    It’s amazing how alot of people don’t even know that you can type an ip address to reach the same url address. I gave a link in the past to a friend of mine but I gave as the ip address with the http in front of it, he got freaked out and thought I was trying to hack him! lol.

    Till then,

    Jean
    used tires´s last blog ..Places to buy used tires My ComLuv Profile

  26. Regim says:

    Thanks for the tips they are very helpful. :)
    Regim´s last blog ..IN REGIM HOTELIER My ComLuv Profile

  27. I know how to add hosts manually in windows but not in Linus and OS/x. This post will surely help a lot of geeks out there.

  28. Thanks for posting this. Saved me a lot of headaches.

  29. Very handy. Cant’ think of when I’d ever need this, but it’s always good to have for if the situation arises.

  30. Gary Cramer says:

    Thanks. Very handy to have. :)

  31. saglik says:

    thanks for sharing

  32. chess man says:

    And is also important to know that it also override the dns settings. Aniway… a good article.

  33. Great Article…now I clear my problem with Setting hosts on Linux…Thanks
    juicy couture´s last undefined ..Response cached until Wed 28 @ 10:53 GMT (Refreshes in 23.99 Hours) My ComLuv Profile

  34. Hello friend thank you today for me is still a major difficulty in setting up Linux, I have no knowledge of this “catch” a bit lol … Thanks!

  35. car battery says:

    I too have many friends that had no idea that an ip address could be used instead of an URL. They thought that ip addresses were simply temporary till a URL was produced for a site!

  36. Excellent tips and advice. When it comes to this type of stuff I am clueless, but your explanation has shed some insight to me and should be very helpful

  37. Thanks for your information, taht’s nice. however, I am not good at computer program, hope I won’t make my computer worse..
    rosetta stone´s last blog ..Rosetta Stone Version 3 Chinese Mandarin- Level 1-2 &amp 3 My ComLuv Profile

  38. Adam Goldman says:

    Thanks, very informative post and I would like to share with you how to speed up mac osx

  39. Adam Goldman says:

    I mean speed up mac os x

  40. david walker says:

    wow its awsome blog, i learn so much by reading your blog especially this article, thanks for share…..
    david walker´s last blog ..Lowa AL S 451 GTX Boot My ComLuv Profile

  41. madicine says:

    thanks for tutorial, its helpful…

  42. Jonas says:

    I needed this since Im developing websites and I want a full domain name. Thanks for sharing
    Jonas´s last blog ..Husgrund – marken spelar roll My ComLuv Profile

  43. it’s complicated..thx for share

  44. kathrine says:

    it a good and helping info. it really help me. thanx

Leave a Reply

CommentLuv Enabled