How to Block a Specific Port on MikroTik Router?

Blocking a port on MikroTik involves creating a new filter rule, specifying the protocol and port, and setting the action to drop.
7 min read
Intermediate
How To Block specific port on mikrotik router

MikroTik RouterOS includes built-in firewall features that let you control network traffic and restrict access to specific ports and IP addresses.

Whether you want to block an unused port, prevent unwanted connections, or improve network security, you can use firewall filter rules to manage incoming, outgoing, and forwarded traffic on your MikroTik router.

In this guide, we’ll show you how to block a specific port using both WinBox and MikroTik Terminal. You can apply these configurations on a physical MikroTik router or a MikroTik VPS from VPSMakers. If you don’t have a MikroTik router yet, explore our MikroTik VPS solutions.

Note:
All steps and configurations in this guide have been tested and verified by the VPSMakers technical team on a MikroTik VPS running RouterOS version 7.25.1. The instructions should also apply to other RouterOS versions; however, some menu options or commands may differ depending on your installed version.

Block a Specific Port on MikroTik Using WinBox

You can block a specific port or all ports using WinBox by creating a firewall filter rule. WinBox provides a graphical interface for configuring firewall rules without dealing with commands. First, connect to your MikroTik VPS, then follow the steps below.

Open MikroTik Firewall Settings

After logging in, on the left-side menu, click on IP and select Firewall, open the Filter Rules tab, and click the + button to create a new firewall rule.

Open MikroTik Firewall Settings

Configure Firewall Rule Port and Protocol

In the General tab, configure the firewall rule by specifying the traffic chain, protocol, and destination port. Select input as the chain if you want to block incoming traffic on your desired port.

Click on the Protocol field and select the protocol you want to block. RouterOS also provides predefined protocol options that you can select directly. Alternatively, choose tcp or udp and specify the port number you want to block in the Dst port field.

The following table explains the main fields you may need to configure when blocking a specific port:

FieldDescription
ChainDetermines how the router processes the traffic. Select input to block connections destined for the MikroTik router itself, or forward to match traffic passing through the router.
Src. AddressSpecifies the source IP address of the traffic. Leave empty to apply rule to all traffic.
Dst. AddressSpecifies the destination IP address of the traffic. Leave empty to apply rule to all traffic.
ProtocolDefines the network protocol. Select tcp or udp or use pre-defined ones.
Src. PortMatches traffic based on its source port. Leave it empty if you don’t want to apply the rule for a specific incoming source port.
Dst. PortSpecifies the destination port you want to block. For example, 8080 either TCP or UDP.
In. InterfaceMatches packets arriving through a specific network interface. Leave it empty if you want to apply to all
Out. InterfaceMatches packets leaving through a specific network interface. This is generally not needed when blocking traffic destined for the router itself; it can be used when forwarding traffic.

Drop Traffic from port on MikroTik

Then switch to the Action tab; in this tab, you need to select drop as the action to drop and reject all incoming traffic to your configured port and settings.

You can also enable logging and add a log prefix to identify connections dropped by this rule.

select drop action on mikrotik firewall rule

Review the Filter Rules

Finally, to ensure that the new rule is listed among the existing ones, check the firewall rules. Based on your setup order, it will often appear at the top or bottom of the list. Be sure that the new rule meets all the necessary criteria, including source and destination addresses, ports, protocols, and actions.

verify firewall rule on MikroTik

Note:
MikroTik firewall rules are processed from top to bottom. If multiple rules match the same traffic, the first matching rule takes effect. To override an existing rule, change their order by dragging the rules up or down in WinBox.

Block a Port Using MikroTik Terminal

You can also block incoming traffic on a specific port or on all ports using MikroTik Terminal with the /ip firewall commands and adding filter rules.

Access your RouterOS console, open a new terminal in Winbox, or connect to your MikroTik VPS via SSH and run the commands below.

Add a Firewall Rule

Use the /ip firewall filter add command to create a new firewall rule. Specify the traffic direction, protocol, destination port, and action to define which connections should be blocked. These parameters are the same as those configured in WinBox, including Chain, Protocol, Dst. Port, and Action.

Run the command below by replacing your values instead of the example ones:

/ip firewall filter add chain=input protocol=tcp dst-port=8080 action=drop comment="Block TCP port 8080"
  • chain: specify input to filter traffic destined for the MikroTik router or forward for traffic passing through.
  • protocol: choose the protocol (udp, tcp) you want to filter.
  • dst-port: Enter the desired port you want to filter.
  • action: Set the action to drop to block matching traffic.
  • comment: This option is optional for you but can work as a note for your rule to be recognized later

Note:
In the example above, we used TCP as the protocol. You can replace it with udp to block UDP traffic on the specified port instead.

Check the firewall rules

After adding the firewall rule, use the command below to verify the rules and their order:

/ip firewall filter print

Unblock a Port in MikroTik

Whether you blocked a port in WinBox or the Terminal, you can unblock it by disabling or removing the firewall rule you created. You can also add an accept rule, but this is not recommended as it can lead to rule conflicts.

Disable and Remove Rule in MikroTik Firewall

To disable the firewall rule using the terminal, first list the firewall rules. Each rule has a number that serves as its ID; use this number to identify and remove the rule. Use the command below to list the firewall rules:

/ip firewall filter print
OUTPUT
0  ;;; Block TCP port 8080 chain=input action=drop protocol=tcp dst-port=8080

Disable firewall rule in MikroTik using the terminal

Instead of removing a rule, you can disable it by running the command below; disabling it can help you use the rule later when required.

/ip firewall filter disable 0

In the command above, 0 represents the rule ID.

How Do MikroTik Firewall Rules Work?

MikroTik RouterOS uses firewall rules to inspect network traffic and determine how it should be handled. Each rule contains matching conditions and an action that RouterOS performs when a packet meets those conditions.

how mikrotik firwall works

Firewall rules are processed from top to bottom, and packets are checked against each rule until a match is found. Depending on the configured action, RouterOS can allow, drop, or reject the traffic. As mentioned earlier, when creating a drop rule to block traffic, make sure to place it above any conflicting rules so that it takes precedence over them.

Each rule can use different matching conditions, including source and destination IP addresses, protocols, ports, and incoming or outgoing interfaces. By combining these conditions, you can control which connections are allowed and which should be blocked.

This allows you to filter traffic from a specific IP address or a range of IP addresses, keep a port accessible to other users, or whitelist a specific IP address so that only it can access a particular port on your MikroTik VPS.

Conlcusion

Blocking a port in MikroTik RouterOS is straightforward once you know how to configure firewall filter rules. You can use either Winbox or Terminal to create a rule, specify the protocol and destination port, and drop incoming matching traffic.

In this guide, we’ve covered both Winbox and terminal methods for blocking ports on MikroTik. You can choose either method depending on your preferred connection and management approach. However, Winbox is generally recommended for beginners because it is easier to use, and its graphical interface makes it easier to understand and manage firewall rules.

Blocking ports and creating other firewall rules gives you greater control over your network and helps prevent unwanted connections to your MikroTik router or VPS.

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 easily update MikroTik router firmware manually using winbox and CLI. Stay up to date with the latest updates!
Jacob Rafet
November 24, 2026
default RDP port is (3389) and to increase the security of all Windows Server 2012, 2016, 2019 and 2022, you can change it with registry editor and PowerShell.
Robert Smith
November 23, 2026
Learn how to change the default MikroTik WinBox port using Terminal or WinBox and allow connections through the new port in the firewall.
Jacob Rafet
November 22, 2026
Learn how to extract regular, multi-part, and password-protected RAR files on Ubuntu VPS using command-line and graphical tools.
Richard Mourar
November 21, 2026