How to Block any IP Address

Deny access to certain websites and services

What to Know

  • In Windows Defender Firewall: Advanced Settings > Inbound Rules > New Rule > Custom. Repeat for Outbound Rules.
  • On Mac: Use Terminal to create a rule in the PacketFilter Configuration file or block the IP address on your network via your router.
  • Block malicious IP addresses to protect your computer from hackers. To block some websites, you may need to block multiple IP addresses.

This article explains how to block an IP address on a Windows or Mac computer.

Can You Block an IP Address?

You can block IP addresses on your computer if you want to deny access to specific websites and services. Some websites use more than one IP address. For example, Facebook has multiple IP addresses, so you'll need to block them all. Disabling individual IP addresses may be helpful if Facebook isn't working for you.

You may want to block an IP address to prevent yourself or other users from accessing specific websites. You should also block malicious IP addresses to protect your computer from hackers and bots.

If you want to block an IP address across your entire network, you can block websites on your router and set up parental controls for your network.

How Do I Block an IP Address From My Computer?

You can block an IP address on a Windows PC using Windows Firewall:

  1. Find the IP address of a website you want to block.

  2. In Windows Search, type Windows Firewall and select Windows Defender Firewall to open it.

    Windows Defender Firewall in Windows Search
  3. Select Advanced settings.

    Advanced Settings in Windows Defender Firewall
  4. Select Inbound Rules, then select New Rule.

    Inbound Rules and New Rule in Windows Defender Firewall
  5. Select Custom, then select Next.

    Custom and Next in Windows Defender Firewall Rules
  6. Select Next on the next two screens to proceed.

  7. Under Which remote IP addresses does this rule apply to, choose These IP Addresses and select Add.

    These IP Addresses and Add in Windows Defender Firewall Rules
  8. Select This IP address or subnet, enter the IP address, and select OK.

    This IP address or subnet and IP address in Windows Defender Firewall Rules
  9. Add as many IP addresses as you like, then select Next.

    Next in Windows Defender Firewall Rules
  10. Select Block the connection, then select Next.

    Block the connection and Next in Windows Defender Firewall Rules
  11. Make sure all the boxes under When Do These Rules Apply? are checked and select Next.

    When Do These Rules Apply? and checkboxes in Windows Defender Firewall Rules options
  12. Give a name and description for the blocked IP address, then select Finish.

    Enter a name and select Finish in Windows Defender Firewall
  13. Select Outbound Rules, then select New Rule and repeat steps 5-11.

    Outbound Rules and New Rule in Windows Firewall Defender
  14. To unblock the IP address, go to Inbound Rules, right-click the name of the rule you created and select Delete. Go to Outbound rules and do the same.

    Delete in Windows Defender Firewall Inbound Rules

How to Block an IP Address on Mac

The easiest way to block IP addresses on a Mac is to block them for your entire network via your router. If you want to block an IP address on just your Mac, use the Terminal to create a new rule in your PacketFilter Configuration file:

  1. Open Terminal and enter the following to open the PacketFilter Configuration file:

    $ sudo vim /etc/pf.conf
  2. Enter the following, replacing IP address with the address you want to block (for example,

    block drop from any to IP ADDRESS

    To block a range of addresses, replace any with an IP address. For example:

    block drop from to
  3. Enter the following to enable the packet filter and load the rule you created:

    $ pfctl -e -f /etc/pf.conf
  4. The IP address is blocked. To disable the rule, enter this command:

    $ pfctl -d
  • How do I hide my IP address?

    To hide your IP address from websites and your internet provider, set up a virtual private network (VPN). With a VPN, you can browse the web without giving away your identity, location, or data.

  • How do I find my IP address?

    There are websites that can help you find your IP address. You can also use the ipconfig command in Windows Command Prompt or ifconfig command in the Mac Terminal.

  • How do I change my IP address?

    To change your IP address on Windows, go to Control Panel > Network and Sharing Center > Change adapter settings. On Mac, go to System Preferences > Network > Advanced > TCP/IP > Manually.

Was this page helpful?