How to Edit Your Hosts File on Windows

On occasion you will need to edit the hosts file on your machine. Sometimes because of an attack or prank, and others so that you can simply and freely control access to websites and network traffic.

hosts files have been in use since ARPANET. They were used to resolve hosts names before DNS. hosts files would be massive documents used to aide the network name resolution.

Microsoft kept the hosts file alive in Windows networking which is why it varies very little whether used in Windows, macOS, or Linux. The syntax stays mostly the same across all platforms. Most hosts files will have several entries for loopback. We can use that for the basic example for the typical syntax.

The first part will be the location to redirect the address to, the second part will be the address that you will want to redirect, and the third part is the comment. They can be separated by a space, but for ease of reading are typically separated by one or two tabs.

127.0.0.1 localhosts #loopback

Windows 7

To access the hosts file in Windows 7 you can use the following command in the Run Line to open notepad and the file.

notepad c:\windows\system32\drivers\etc\hosts

sshot-2010-08-31-[19-41-19]

Once notepad is open you can edit the file. In this example we will block Facebook. To do this just enter in the following after the # mark.

0.0.0.0    www.facebook.com

sshot-2010-08-31-[20-51-49]

Now that you have edited your Hosts file make sure to save it.

sshot-2010-08-31-[20-54-07]

Now notice if we try to access Facebook in IE we can’t get to the page.

sshot-2010-08-31-[20-56-44]

We also were not able to get to it in Google Chrome… (check notes at the end). Also for more info on editing your Hosts file, check out The Geek’s article on how to create a shortcut to quickly edit your Hosts file.

sshot-2010-08-31-[21-04-27]


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值