Take the 2-minute tour ×

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
add comment

2 Answers

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    superuser.com

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

share|improve this answer
add comment

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 <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, you should choose a destination IP of e.g. - 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
add comment

Your Answer


