How to Prevent Access to IPs and Webs in Windows from PowerShell

The Internet has become a key element for most users, either working on a PC, or using a mobile. That is why right now, the Windows operating system presents us with some very important integrated functions related to security.

These what allow us is, on the one hand, to protect the equipment and all the data stored in it, from potential external attacks. In addition we can also take certain measures to prevent certain websites from being accessed. Whether for security, privacy or because we want to prevent access to some Internet site, Windows itself provides us with tools that can be very helpful in this regard.

Prevent Access to IPs and Webs

Windows provides us with many security functions

And we must bear in mind that everything related to security and privacy is more important than ever at the moment. For this we have first hand, elements such as the operating system firewall , or Windows Defender , elements that we recommend activating and using.

Firewall de Windows

But that is not all in this same sense, since the most advanced users will also be able to use certain internal commands. Serve as an example that the PowerShell application comes with a Netsecurity module that allows us to configure the Windows Firewall from here. In this way we have the possibility of using the New-NetFirewallRule function to block a specific IP, or a web. In addition, all of this can be carried out through the aforementioned Windows PowerShell .

With all this what we do is create a new rule for the incoming or outgoing firewall, which in turn is added to the computer. While blocking IP ranges works perfectly, blocking a website or domain is somewhat more complicated. This is because there may be multiple IPs attached to the same domain .

And although we can always avoid them, DNS can find out a different IP every time we make a query. In addition, sometimes the same IP can be used by related services, so blocking it would also mean blocking other platforms.

How to block local or Internet IP addresses

The first thing we must know for all this is that we need to have administrator permissions to execute the PowerShell commands that we are going to propose. So, first of all what we will do is block an IP or range of these from this Windows function. Say that using this command that we will show you, it is executed on a single IP address, or on a range. Thus, we open the PowerShell with administrator permissions and execute the following command:

“New-NetFirewallRule -DisplayName” URL_MUESTRA.com IP address “-Direction Outbound –LocalPort Any -Protocol TCP -Action Block -RemoteAddress IP BLOCKED / 23”

Saying that we replace the text SAMPLE_URL with some term that is easy to remember or understand every time we see it. Also at the end, IP BLOCKED will be the real IP address that we are going to block with this command.

PowerShell bloquear IP

Therefore, any website or service that corresponds to that specified IP will be blocked from now on. Another point that we should bear in mind at this point is that we can also replace the RemoteAddress parameter with LocalAddress if the IP we are dealing with belongs to a local network.

As you can imagine, this is something that we can do with as many IPs as we want. In addition, they will be added to the Firewall that Windows integrates , where in turn we can check the entries that we have added from PowerShell.

Different ways to block a certain website

We must know that the function that we have told you about here does not support blocking a URL directly, but we have other options. The first is to consult all the possible IPs of that domain and block them as we have taught you before. The second is to find the known official IP ranges and block them in the same way. Of course, you should know that the second method mentioned has less possibilities of accidentally blocking other services compared to the first.

That being said, if blocking a domain is very important to us, you can always use other third-party software to block them. And it is necessary to take into account that, whether by own decision or to take care of other users , such as the little ones in the house, it is necessary to monitor the websites that are visited.

Parental control applications

At this point, if instead of using the commands proposed by the Windows PowerShell application, we want to go one step further, let’s see what we can do. We refer to the possibility of having some control over the websites that can be visited from our PC. Whether for personal control , or for others, such as minors who use the PC, there are programs that can be very helpful. This is where applications called parental controls come into play.

These are programs that focus on allowing us to control Internet use on that PC, something that includes blocking certain websites. In fact if the computer is also used by minors, these programs will never hurt. Therefore, to say that Windows 10 itself has its own functionality in this regard. This is something that we can activate from the Settings / Accounts / Family and other users / Add family application.

Control parental Windows

At the same time in the market we can also use a good number of solutions in this same sense that will be very useful to us. Specifically, we refer to some useful parental control programs that we have talked about on some occasions in the past.