How to Block a Website on a MikroTik VPS?

Learn how to block websites on MikroTik using DNS filtering, Layer 7 protocols, and TLS Host rules. Includes WinBox and CLI instructions.
13 min read
Intermediate
Block a Website on a MikroTik VPS

Blocking websites on a MikroTik VPS can be useful for restricting access to unwanted websites, preventing users from visiting distracting or potentially harmful content, and managing internet access across your network. This action can help network administrators control which online resouces are available to connected devices.

MikroTik RouterOS provides several ways to block websites, including firewall rules and DNS filtering. The best method depends on your network configuration and the type of traffic you want to restrict.

In this guide, we’ll walk you through how to block websites on MikroTik using DNS filtering, Layer 7 protocols, TLS Host filtering, and firewall rules. We’ll also cover how to unblock websites, manage existing filtering rules, and troubleshoot common issues when configuring these methods on your MikroTik VPS.

Note:

All steps in this guide have been tested and verified by the VPSMakers technical team on a MikroTik VPS running the latest MikroTik RouterOS version 7.25.2. The same methods can also be followed on other RouterOS versions, although some interface details may differ.

Your WinBox version may also look different from the one used in this guide. If you want to follow the screenshots more closely, we recommend updating WinBox to the latest version.

Block Websites Using DNS Filtering on MikroTik

DNS Filtering allows you to control how MikroTik responds to DNS requests for specific domains. In this method, you can configure MikroTik to, instead of returning the actual website IP address, return another IP address or NXDOMAIN Reponse.

This method has some limitations and is best suited for basic website filtering. If a connected device uses an external DNS resolver instead of your MikroTik DNS, it can bypass the filtering rules and access the blocked websites. Otherwise, the configured filtering rules will apply.

Enable DNS Remote Requests

First, connect to your MikroTik VPS through WinBox and in the left sidebar navigate to IP > DNS. On the opening page, enable the Allow Remote Requests option, click Apply, then click OK. This allows devices connected to your MikroTik network to use it as their DNS resolver.

Enable Allow Remote DNS requests in MIkroTik

Add Website to Static DNS on MikroTik

Now, create a new static DNS entry for the website domain you want to block. In the example below, we’re using youtube.com, but you can replace it with any domain you want to filter or block.

Navigate to IP > DNS and click the Static button on the right sidebar. In the Static tab, click New to create a new entry, then fill in the fields according to the instructions below.

Navigate to DNS Static Page in MikroTik

In the table below, you can see example values; replace youtube.com with your desired domain name and replace 192.168.1.100 with your MikroTik VPS public IP address.

SettingValue
Nameyoutube.com
TypeA
Address192.168.1.100
Match SubdomainEnabled

Note:

Here, instead of setting Type to A you can set it to NXDOMAIN, which instead of redirecting to another IP address it returns non existing domain response. Both can work correctly, but NXDOMAIN is generally cleaner.

Create New Static DNS Entry in MikroTik

Note:

With this configuration, when a device connected to your MikroTik tries to access youtube.com, MikroTik returns its own IP address instead of YouTube’s actual IP address. As a result, the device cannot establish a connection to YouTube.

Configure DNS for Connected Devices

For DNS filtering to work, connected devices must use your MikroTik VPS as their DNS resolver. If you’re using MikroTik locally with a DHCP server, set your MikroTik gateway IP address as the DNS server in your DHCP configuration. Similarly, if you’re using MikroTik as a VPN server, configure the VPN clients to use the MikroTik gateway IP as their DNS server.

If you don’t have any VPN servers on your MikroTik, you can follow the guide below to set up two popular VPN setups on MikroTik.

Learn how to set up an L2TP VPN server on MikroTik with IPsec, user accounts, IP pools, NAT, and firewall rules for secure remote access.

Read the full article

In this guide you will learn how to set up OpenVPN tunneling protocol in MikroTIk using Winbox solution and understand its limitations.

Read the full article

Warning:

Keep in mind that devices using external DNS servers, DNS over HTTPS (DoH), or cached IP addresses may bypass this configuration. Additional firewall rules may be necessary to restrict alternative DNS access.

Test Website Blocking

After saving the configurations, connect a device to your MikroTik network and try accessing the blocked website. You can also check the DNS response using Windows CMD.

nslookup example.com

If you’ve configured an IP redirection, the response should show your MikroTik IP address. If you configured NXDOMAIN, the DNS query should report that the domain does not exist.

If the device still resolves the original IP address, clear its DNS cache:

ipconfig /flushdns

You can also check whether the device is using an external DNS resolver instead of your MikroTik VPS.

How to Prevent Bypassing MikroTik DNS Filtering

As mentioned, if the user uses another DNS Server instead of your MikroTik, they can still access the destination website, howerver you can create a NAT rule that redirects DNS requests to your MikroTik DNS resolvers, regardless of which DNS server the connected device has configured.

To do this, navigate to IP > Firewall > NAT in WinBox and create two NAT rules using the following configurations: one for UDP and another for TCP connections.

SettingUDP RuleTCP Rule
Chaindstnatdstnat
Protocoludptcp
Dst. Port5353
Actionredirectredirect
To Ports5353
Setup NAT rule for redirecting DNS requests in mikrotik
Set Nat Action to redirect to port 53 in MikroTik

This forces standard DNS requests to pass through your MikroTik DNS resolver, allowing your configured filtering rules to apply even when devices use external DNS servers.

Note:

This method does not block DNS over HTTPS (DoH), DNS over TLS (DoT), or direct IP connections. IF you need more advanced filtering, you can use MikroTik Layer 7 Protocol filtering with RegEx, although it has limitations with encrypted traffic and can consume additional router resources.

Block a Website Using Layer 7 Protocol in MikroTik

If you want to block a website that is hard to bypass, MikroTik RouterOS also supports Layer 7 Protocol filtering, which allows you to identify specific patterns in network traffic using Regular Expressions (RegEx). You can use this feature to match website domains in unencrypted HTTP requests and create firewall rules to drop matching connections.

Unlike DNS filtering, this method inspects network traffic to find matching patterns rather than modifying DNS responses. However, Layer 7 filtering has an important limitation with modern HTTPS websites, as their HTTP requests and hostname information are encrypted.

Create a Layer 7 Protocol Rule

First, connect to your MikroTik VPS and navigate to IP > Firewall > Layer 7 Protocols. Click the New + Button to create a new Layer 7 Protocol entry and configure the following fields:

SettingValue
Nameblock-youtube
Gegexp^.*Host:.youtube.com.$

In the example above, we’ve used youtube.com but you can replace it with any website you want to block. Since writing regular expressions manually can be difficult, you can use AI tools like ChatGPT to generate the appropriate regex pattern for your desired domain.

Then click Apply and OK to save the configurations.

Create new Layer 7 Protocol entry in MikroTik Firewall

Create a Firewall Filter Rule in MikroTik

Now you need to create a firewall rule that uses the Layer 7 protocol you just configured. Navigate to IP > Firewall > Filter Rules, click New + and under the General tab, configure the options like the table below.

SettingValue
Chainforward
Protocoltcp
Dst. Port80

Next, switch to the Advanced tab and select the protocol you created under Layer7 Protocol. Then, go to the Action tab, set the action to drop, and click Apply followed by OK.

Create Firewall Rule to use Layer 7 Protocl in MikroTik to Block Website

Block Website With Layer 7 Protocol Using CLI

If you prefer to use the Command Line Interface instead, you can create the same protocol and firewall filter rule by running a few commands in the MikroTik terminal.

In the command below, replace name and regexp We’ve used as examples with your own values and run the commands.

/ip firewall layer7-protocol add name=block-youtube regexp="^.*Host:.*youtube\\.com.*$"

Next, run this command to create a firewall rule and use the protocol you’ve created in layer7-protocol Replace your protocol name you’ve set in the previous command:

/ip firewall filter
add chain=forward protocol=tcp dst-port=80 layer7-protocol=block-youtube action=drop comment="Block YouTube HTTP"

To check your configurations, execute:

/ip firewall layer7-protocol print
/ip firewall filter print

Important Limitations of Layer 7 Filtering in MikroTik

Although Layer 7 filtering can identify website domains through RegEX, it is important to understand its limitations before relying on it for website blocking.

  • HTTPS encryption: Layer 7 filtering cannot normally inspect encrypted HTTPS requests to identify domain names; the steps we’ve covered are for unencrypted HTTP traffic.
  • Performance: Using Layer 7 filering is resouce consumes a lot of resources because RouterOS needs to inspect packets content, so to use it you may need higher CPU and RAM resouces.
  • QUIC: Websites using QUIC over UDP port 443 are not matched by the TCP rule described above.
  • Packet inspection: RouterOS only inspects the first 10 packets or the first 2 KB of the connection. If it cannot find a matching pattern within that data, it stops inspecting the connection.

Recommendation:

Layer 7 Protocol filtering is not the best choice for blocking general websites that use HTTPS primarily. For general website blocking, DNS filtering is usually more practical; however, it is bypassable too.

If you need to identify HTTPS domains through firewall rules, consider using the TLS host matcher available in RouterOS 7, while keeping its limitations in mind.

Block HTTPS Websites Using TLS Host in MikroTik

Unlike regular DNS filtering, MikroTik can also use the TLS Host matcher to block HTTPS connections to specific websites. This method checks the hostname provided during the TLS handshake, allowing you to filter HTTPS traffic without decrypting it.

Create a Firewall Filter Rule in MikroTik

In the WinBox sidebar, navigate to IP > Firewall > Filter Rules and click New + to create a rule. Then configure the required fields as shown in the next steps.

In the General tab, configure chain, protocol, and Dst. Port, following the table below:

Chainforward
Protocoltcp
Dst. Port443
Create Firewall Rule in MikroTIk and use TLS handshake filtering

Then switch to the Advanced tab and scroll down to find the TLS Host field. Enter the domain name of the website you want to block, such as youtube.com. To match all its subdomains, you can use a wildcard like *.youtube.com. Alternatively, you can create a separate rule for each subdomain.

Next, switch to the Action tab, set the action to drop, and click Apply and OK.

Set TLS Host Field and Drop the connection in MikroTik firewall

Block Websites Using TLS Host in MikroTik Using CLI

Instead of using WinBox, you can create the rule by running a single command in the MikroTik terminal. Replace the tls-host value with your desired domain (we’ve used youtube.com as an example) and run the command.

This command adds a rule to the main domain:

/ip firewall filter add chain=forward protocol=tcp dst-port=443 tls-host=youtube.com action=drop comment="Block YouTube"

The command below blocks all subdomains of your domain, for example, youtube.com:

/ip firewall filter add chain=forward protocol=tcp dst-port=443 tls-host=*.youtube.com action=drop comment="Block YouTube subdomains"

Note:

In the commands above, replace the youtube.com with your desired website domain name and run the commands to create the firewall rule.

Important Limitations of Blocking Websites With TLS in MikroTik

Although TLS Host filtering can block many HTTPS connections, it has some limitations too:

  • QUIC traffic: This method matches TCP traffic on port 443, but some browsers use QUIC over UDP port 443. These connections will not match the rules.
  • Encrypted ClientHello (ECH): Some connections can use ECH to hide the requested hostname, preventing MikroTik from matching it.
  • Fragmented TLS handshakes: If the TLS ClientHello is split across multiple TCP segments, the matcher may fail to identify the hostname, so traffic goes through.

TLS Host filtering is useful for blocking many websites, but it is not a guaranteed way to prevent all access. For more comprehensive filtering, you may need to combine it with DNS filtering and other firewall rules.

How to Unblock a Website in MikroTik

To unblock a website, you need to remove or disable the filtering rules you created for that website. The steps depend on which filtering method you used previously.

If you cannot access a website because it is blocked by upstream firewalls rather than your own MikroTik firewall rules, you can buy MikroTik VPS in another location without these restrictions. Then, connect your existing MikroTik router to the VPS using a site-to-site VPN or another suitable tunneling method to access the resources you need.

If you want to remove the DNS filtering, open IP > DNS > Static in Winbox and remove the static DNS entry you’ve created fr blocked domain. If you no longer want to use MikroTik as their DNS resolver, you can also disable allow remote requests under IP > DNS. Then restore the DNS server settings you’ve changed in your DHCP configurations or VPN setup.

In Layer 7 Protocol filtering and TLS Hosting filter, easily navigate to IP > Firewall and locate the rule and disable or remove it.

Note:

After removing or disabling the relevant rules and DNS entries, clear the DNS cache on client devices or reconnect them if necessary. The website should then become accessible again, provided no other firewall or network rule is blocking it.

Frequently Asked Questions About Blocking Websites in MikroTik

Can I block HTTPS websites using MikroTik?

Yes. You can use the TLS Host matcher in firewall filter rules to block many HTTPS connections based on their hostname. However, there are some limitations.

Which method is best for blocking websites in MikroTik?

All methods can work well; however, DNS filtering is generally the simplest option for blocking domain access on your network. TLS host filtering can help with HTTPS traffic, and Layer 7 filtering can be used for unencrypted traffic.

The best method depends on your network filtering requirements. For more comprehensive filtering and control, consider combining two or more methods, as each has its own limitations.

Can users bypass MikroTik website blocking?

Yes. Users may bypass filtering by changing their DNS servers, using DNS over HTTPS (DoH), connecting directly using IP, or using a VPN. You may need additional firewall rules to restrict some of these methods.

Can I block only specific pages of a website?

Not reliably with the methods covered in this guide. DNS and TLS Host filtering work at the domain or hostname level, not at the individual webpage URL or path level.

Does website blocking affect all devices connected to MikroTik?

It depends on how you configure the rules. DNS filtering can affect all devices using MikroTik as their DNS resolver, while firewall filtering rules can be scoped to specific IP addresses, subnets, or interfaces.

Summary

MikroTik RouterOS provides several ways to block websites, including DNS filtering, Layer 7 Protocol filtering, and TLS Host filtering. DNS filtering is generally the simplest option for restricting access to specific domains, while using Layer 7 and TLS Host filtering, you can get more control.

Each method has its own limitations, especially when dealing with encrypted HTTPS traffic, QUIC, and alternative DNS resolvers. For better website filtering, you need to use a combination of these methods to control traffic on your network.

By choosing the right filtering rules and configuring them correctly, you can better control website access across devices connected to your MikroTik network.

Share:

Was this article helpful?

Your feedback helps us improve our technical guides.

Related Posts

You May Also Like

Explore more tutorials, guides, or documentation, from VPSMakers.

Learn how to set up XRDP on Ubuntu Server, install a graphical interface, configure Xorg, and access your server through an RDP client.
Richard Mourar
November 29, 2026
Learn how to block websites on MikroTik using DNS filtering, Layer 7 protocols, and TLS Host rules. Includes WinBox and CLI instructions.
Jacob Rafet
November 29, 2026
Learn how to temporarily or permanently disable IPv6 on Ubuntu, Debian, and other Linux distributions with simple commands.
Robert Smith
November 28, 2026
Learn how to easily update MikroTik router firmware manually using WinBox and CLI. Stay up to date with the latest updates!
Jacob Rafet
November 24, 2026