Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

The hosts file is used to map hostnames to IP addresses. However, I only have an IP address. I tried using HostsMan, but it doesn't want to even add the line.

How do I add a line to the hosts file if I only have an IP address?

share|improve this question

2 Answers 2

The hosts file is one of several methods by which the operating system looks up the IP-address corresponding to a hostname.

The "hostman" editor is an editor for this file.

The hosts file is a text file and can be edited using any text editor, for example notepad. You just have to be careful to conform to the format rules for hosts files.

The hosts file can't be used to forbid access to an IP-address but it can be used to give the operating system a false IP-address for a hostname you want to block. For example if you add the line

127.0.0.1    superuser.com

You will then no longer be able to access this website.

share|improve this answer

You can use a blackhole route to prevent any packet destined to a certain IP/block of IPs to even getting to a router by

route -p ADD <ip you want to block> MASK 255.255.255.255 <destination IP>

You should choose a destination IP from your local network if you are behind NAT. If you are directly connected to the Internet, this will probably not work.

For example, if your IP is 192.168.0.155, you should choose a destination IP of e.g. 192.168.0.166 - anything but your router's address.

Perhaps a better solution is to use firewall. To add a rule is simple, just type

netsh advfirewall firewall add rule name="Block IP" dir=out remoteip=<remote ip> action=block

This will work no matter how you are connected to the internet, so it should be preferred. But if you don't have Windows Firewall running, this may not work while the first method does not depend on the firewall.

You can get additional information about Windows Firewall commands on Microsoft Technet Page

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.