 | | Welcome to Windows 7 Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows 7. The Windows 7 forum also covers news and updates and has an extensive Windows 7 tutorial section that covers a wide range of tips and tricks. | Windows 7 - Hosts File : Use in Windows 7 / Vista
Hosts File : Use in Windows 7 / Vista How to Access and Use the Windows Hosts File in Windows 7 and Vista
Published by Bare Foot Kid
04-14-2010
| Hosts File : Use in Windows 7 / Vista How to Access and Use the Windows Hosts File in Windows 7 and Vista
This will give you the basics on how to use the Windows Hosts File, it's not very complicated but it's up to each individual to find additional information and put it to good use to suite your needs.  Note To block a site this "127.0.0.1 localhost" (without the quotes) must be the first entry in the Hosts File, you can add any comments to the file using this ( # ) symbol at the front of the comment; each entry needs its own line and there must be at least 1 space between the IP address and the host name; this info can be viewed in the #1 snip below of the default Windows 7 Hosts File.
Some sites have more than one IP address so to completely block a specific site you may need to add more than one entry to completely block such sites.  Tip As any additions / changes to the Hosts File can / will be removed using a System Restore point dated before the work was done with the file, it may be a good idea to create Restore Points before and after any changes are made to the Hosts File, see the tutorial at the link below. System Restore Point - Create
It would also be advisable to clear the DNS Resolver Cache whenever you finish working with the Hosts File, open an elevated command window and type "ipconfig /flushdns" (without the quotes) and hit enter. Let's get started!
1) In the Windows start menu search box type "notepad" (without the quotes) right click the entry and select "Run as Administrator" then enter your user credentials for the UAC prompt and click yes to open notepad. In notepad at "File" select "Open" then browse to C:\Windows\System32\drivers\etc in the window that opens select "All Files" then "hosts" then click "Open" to open the default Windows Hosts File location.      2) The #1 snip below is the default Windows 7 Hosts File that opens, as you can see with the use of this ( # ) symbol, Windows does not "read" any of the default information in the file, so it's up to you whether to delete it all or not but it may be useful to leave it there for future reference. 3) If I wanted to block access to ebay.com, the first entry in the file would need to be 127.0.0.1 localhost on its own line, on the next line I would add 127.0.0.1 ebay.com with at least 1 space between the IP address and the host name; then back at "File" select "Save" then "Exit" to close notepad.  
Option Two Re-direct a Site
If I wanted to re-direct ebay.com to sevenforums.com I would add the IP address for sevenforums.com on its own line seperated by at least 1 space then ebay.com, and if I wanted to add comments I would put them after the # symbol; then at "File" select "Save" then "Exit" to close notepad.
To ping a site to get the IP address, open a command window (it doesn't have to be elevated) type "ping ebay.com" then hit enter, as you can see in the snip there's one of the IP addresses for ebay.com; those are common ping commands in the "Code" box below.
Code:
Microsoft Windows [Version 6.1.7601]
Copyright (c) 2009 Microsoft Corporation. All rights reserved.
C:\Users\Bare Foot Kid>ping /?
Usage: ping [-t] [-a] [-n count] [-l size] [-f] [-i TTL] [-v TOS]
[-r count] [-s count] [[-j host-list] | [-k host-list]]
[-w timeout] [-R] [-S srcaddr] [-4] [-6] target_name
Options:
-t Ping the specified host until stopped.
To see statistics and continue - type Control-Break;
To stop - type Control-C.
-a Resolve addresses to hostnames.
-n count Number of echo requests to send.
-l size Send buffer size.
-f Set Don't Fragment flag in packet (IPv4-only).
-i TTL Time To Live.
-v TOS Type Of Service (IPv4-only. This setting has been deprecated
and has no effect on the type of service field in the IP Head
er).
-r count Record route for count hops (IPv4-only).
-s count Timestamp for count hops (IPv4-only).
-j host-list Loose source route along host-list (IPv4-only).
-k host-list Strict source route along host-list (IPv4-only).
-w timeout Timeout in milliseconds to wait for each reply.
-R Use routing header to test reverse route also (IPv6-only).
-S srcaddr Source address to use.
-4 Force using IPv4.
-6 Force using IPv6. Enjoy  |  Published by | | Original Team Member Join Date: Jun 2008 Location: The Lowcountry Posts: 23,809 | |
 Tutorial Tools | | | | | | | | | |
04-14-2010
|
#1 | | Windows 7 Ultimate, Ubuntu 10.04 LTS - the Lucid Lynx |
Great Work Jr. Brink | My System Specs | | System Manufacturer/Model Number Custom Build OS Windows 7 Ultimate, Ubuntu 10.04 LTS - the Lucid Lynx Motherboard Asus A8N-VM Memory 2 GB Graphics Card Nvidia GeForce 6150 Sound Card Sound Blaster Audigy 24-Bit Monitor(s) Displays Samsung SyncMaster 2253LW 21.6" Widescreen LCD Monitor Hard Drives 320 GB - Internal
1 TB WD External |
04-14-2010
|
#2 | | Vista Ult 64 bit Seven Ult RTM x64 |
Good info Ted. Thanks. | My System Specs | | System Manufacturer/Model Number Dell XPS420 OS Vista Ult 64 bit Seven Ult RTM x64 CPU Intel Core2 Quad Q6600 2.40 gigahertz Memory Crucial Ballistix 4x2GB PC2 6400 Graphics Card NVIDIA GeForce 8600 GTS 256 MB Sound Card Creative SB X-Fi audio Monitor(s) Displays HP w2207 + HPvs15 Screen Resolution 1680x1050 + 1024x768 Keyboard Microsoft Comfort Curve Mouse MX Revolution Hard Drives 2-WD5000AAKS-500 GB
WD5000AAV-500 GB external Other Info Wacom Intuos 2 Graphics Tablet
Experience Index=5.5 |
04-14-2010
|
#3 | | |

Quote: Originally Posted by Capt.Jack Sparrow Great Work Jr. Brink  
Quote: Originally Posted by garysgold Good info Ted. Thanks. 
Hello Cap'n and Gary, thanks! | My System Specs | | System Manufacturer/Model Number * BFK Customs * OS W 7 64-bit Ultimate CPU Intel Q9550 Yorkfield Motherboard ASUS P5Q Pro Memory 8GB Dominator 8500C5D Graphics Card ATI : XFX 5870 Sound Card Realtek HD Audio 7-1 Monitor(s) Displays 1x 47" LCD HDMI & 3x 26" LCD HDMI Screen Resolution 1920x1080P & 1920x1200 Keyboard Microsoft 500 Mouse Razer Diamondback 3G PSU Corsair 620HX Case Cooler Master RC-690 Cooling Tuniq Tower 120, 2x 140mm and 3x 120mm case fans Hard Drives 1x 80GB Intel X25-M G2 SSD : 1x 500GB & 1x 640GB WD Caviar Black(s) Internet Speed 14 Mb/s Other Info 1x Koutech 3Gb/s SATA HDD Hot Swap Rack |
04-14-2010
|
#4 | | Windows 7 Ultimate 32 bit |
Very good instructions, Ted. Great job. | My System Specs | | System Manufacturer/Model Number Home built OS Windows 7 Ultimate 32 bit CPU Intel(R) Pentium(R) 4 CPU 3.00GHz Motherboard ASUS P4P800-VM Motherboard Chipset: Intel 865G + ICH5 Memory 2.50 GB RAM Graphics Card NVIDIA GeForce 7600 GS Sound Card SoundMax Integrated Digital Audio (Chip) Monitor(s) Displays ViewSonic VX 1962 wm Screen Resolution 1680 X 1050 Keyboard Microsoft Comfort Curve Keyboard 2000 v10 USB Mouse Logitec optic USB Cooling Fan based Hard Drives Seagate Barracuda 7200.10 80 GB
ST380215A ATA Device 18.6 GB
Western Digital "My Book" external hard drive 750 GB Internet Speed 3.01 Mb/s download 0.64 Mb/s upload |
04-14-2010
|
#5 | | |
Thanks Carl! | My System Specs | | System Manufacturer/Model Number * BFK Customs * OS W 7 64-bit Ultimate CPU Intel Q9550 Yorkfield Motherboard ASUS P5Q Pro Memory 8GB Dominator 8500C5D Graphics Card ATI : XFX 5870 Sound Card Realtek HD Audio 7-1 Monitor(s) Displays 1x 47" LCD HDMI & 3x 26" LCD HDMI Screen Resolution 1920x1080P & 1920x1200 Keyboard Microsoft 500 Mouse Razer Diamondback 3G PSU Corsair 620HX Case Cooler Master RC-690 Cooling Tuniq Tower 120, 2x 140mm and 3x 120mm case fans Hard Drives 1x 80GB Intel X25-M G2 SSD : 1x 500GB & 1x 640GB WD Caviar Black(s) Internet Speed 14 Mb/s Other Info 1x Koutech 3Gb/s SATA HDD Hot Swap Rack |
04-14-2010
|
#6 | | Vista and Windows7, sometimes Ubuntu and Fedora |
Very nice, thank you. That merits some reps. | My System Specs | | System Manufacturer/Model Number HP, Dell, Gateway - 2 laptops and 2 desktops OS Vista and Windows7, sometimes Ubuntu and Fedora CPU from 1.6GHz Duo to 2.5GHz Quad Monitor(s) Displays 2x HP w2207 Keyboard with trackball - no mices Mouse terrible devices, who wants them Hard Drives 5x HDD, 2x SSD, 6x Externals Internet Speed DSL 6000 |
04-14-2010
|
#7 | | |
Thank you very much! | My System Specs | | System Manufacturer/Model Number * BFK Customs * OS W 7 64-bit Ultimate CPU Intel Q9550 Yorkfield Motherboard ASUS P5Q Pro Memory 8GB Dominator 8500C5D Graphics Card ATI : XFX 5870 Sound Card Realtek HD Audio 7-1 Monitor(s) Displays 1x 47" LCD HDMI & 3x 26" LCD HDMI Screen Resolution 1920x1080P & 1920x1200 Keyboard Microsoft 500 Mouse Razer Diamondback 3G PSU Corsair 620HX Case Cooler Master RC-690 Cooling Tuniq Tower 120, 2x 140mm and 3x 120mm case fans Hard Drives 1x 80GB Intel X25-M G2 SSD : 1x 500GB & 1x 640GB WD Caviar Black(s) Internet Speed 14 Mb/s Other Info 1x Koutech 3Gb/s SATA HDD Hot Swap Rack |
04-14-2010
|
#8 | | |
Thanks for doing this. You may want to add that you can also 'tab' the IP/Hostname entries to make neat looking columns. | My System Specs | | System Manufacturer/Model Number Dell M6300 OS Windows 7 Professional CPU Intel Duo 2.4 Motherboard Dell Memory 4 Gb Graphics Card Nvidia Quadro FX1600M Monitor(s) Displays integrated 17 inch Screen Resolution 1920x1200 Mouse Logitec VX nano Hard Drives Seagate 320Gb Internet Speed DSL |
04-14-2010
|
#9 | | |
Hello Jeff, you're welcome. | My System Specs | | System Manufacturer/Model Number * BFK Customs * OS W 7 64-bit Ultimate CPU Intel Q9550 Yorkfield Motherboard ASUS P5Q Pro Memory 8GB Dominator 8500C5D Graphics Card ATI : XFX 5870 Sound Card Realtek HD Audio 7-1 Monitor(s) Displays 1x 47" LCD HDMI & 3x 26" LCD HDMI Screen Resolution 1920x1080P & 1920x1200 Keyboard Microsoft 500 Mouse Razer Diamondback 3G PSU Corsair 620HX Case Cooler Master RC-690 Cooling Tuniq Tower 120, 2x 140mm and 3x 120mm case fans Hard Drives 1x 80GB Intel X25-M G2 SSD : 1x 500GB & 1x 640GB WD Caviar Black(s) Internet Speed 14 Mb/s Other Info 1x Koutech 3Gb/s SATA HDD Hot Swap Rack Hosts File : Use in Windows 7 / Vista problems? All times are GMT -5. The time now is 10:22 PM. |  |