DropVPS Team
Writer: Cooper Reagan
How to block port in mikrotik?

Table of Contents
What you will read?
Blocking ports is a crucial security measure that can significantly enhance network security. By restricting access to specific ports, you can prevent unauthorized access, mitigate the risk of cyberattacks, and maintain control over the services your network offers. This strategic approach helps safeguard your network infrastructure and protect sensitive data from potential threats.
Methods of Blocking Ports in MikroTik
MikroTik offers multiple methods to block ports, tailored to different user preferences. For those who prefer a graphical interface, Winbox provides a user-friendly way to create new firewall rules, configuring the chain, protocol, and port to be blocked. Alternatively, for advanced users, the terminal interface offers direct command-line access, allowing for precise control over port blocking using specific commands and practical examples.
Step-by-Step Guide to Block a Port in Mikrotik
To block a port in Mikrotik, you can follow these simple steps. This guide will help you set up firewall rules to block specific ports, either for incoming or outgoing traffic, using Mikrotik’s RouterOS interface.
Access Mikrotik RouterOS
The first step is to log into your Mikrotik router. You can access the router using Winbox, WebFig, or SSH. Open the interface and enter your login credentials.
Navigate to the Firewall Settings
Once logged in, go to the “IP” menu in the left sidebar and select “Firewall.” This will take you to the firewall configuration window, where you can manage your firewall rules.
Add a New Firewall Rule
In the “Firewall” window, click on the “Filter Rules” tab and then click the “+” button to add a new rule. This will allow you to define the criteria for blocking the port.
Define the Chain for Blocking Traffic
In the new rule configuration, you’ll need to specify the chain type. If you’re blocking incoming traffic, set the chain to “Input.” If you’re blocking forwarded traffic (traffic passing through the router), set the chain to “Forward.”
Select the Protocol
Next, you need to define the protocol for the rule. Typically, this will be either TCP or UDP, depending on the type of traffic you want to block. If you are unsure, TCP is the most commonly used protocol for ports.
Specify the Port Number
In the “Dst. Port” field, enter the port number that you want to block. For example, if you want to block HTTP traffic, you would enter port 80. For HTTPS, enter port 443. You can block multiple ports by separating them with a comma.
Set the Action to Drop
To block the traffic, go to the “Action” tab and select “Drop.” This will ensure that any traffic matching the rule is discarded and prevented from reaching its destination.
Apply the Rule
After setting up the rule, click “OK” to apply the changes. Your firewall rule will now block the specified port for incoming or forwarded traffic based on your configuration.
Test the Port Block
To ensure the port is successfully blocked, you can use tools like “telnet” or “nc” (Netcat) to attempt a connection to the blocked port. If the connection is denied, the port is successfully blocked.
Blocking Specific Ports vs. Blocking All Ports in Mikrotik
When it comes to securing your network in Mikrotik, two common strategies involve either blocking specific ports or blocking all ports. Both methods serve different purposes, and it’s important to understand their differences and use cases.
Blocking Specific Ports
Blocking specific ports in Mikrotik allows you to control which types of traffic are allowed to pass through your router. This is a more granular approach, often used to block specific services or applications that may pose a security risk.
For example, you might want to block HTTP traffic on port 80 to prevent web servers from being accessed, while still allowing other types of traffic like DNS or email. This allows for more flexibility, as you can selectively block unwanted services without affecting other necessary communications.
To block specific ports, you create firewall rules targeting the ports you want to block, as explained in the previous section.
Advantages of Blocking Specific Ports
- Fine-grained control over network traffic.
- Allows necessary services to continue running while blocking others.
- More efficient for controlling specific types of traffic.
Disadvantages of Blocking Specific Ports
- Requires knowledge of which ports need to be blocked.
- May miss other vulnerabilities if not all relevant ports are blocked.
Blocking All Ports
Blocking all ports is a more extreme approach, often used as a security measure when you want to ensure that no inbound or outbound traffic can pass through the router. This method essentially isolates the network, preventing any external access to your devices.
Blocking all ports can be useful in certain high-security environments, or when you need to temporarily disconnect devices from the internet for maintenance or troubleshooting. However, it’s important to note that this approach will also block legitimate traffic, such as web browsing or email.
Advantages of Blocking All Ports
- Provides complete isolation from the internet.
- High security, as it prevents all external access.
Disadvantages of Blocking All Ports
- Completely disables all internet and network services.
- Not practical for regular use, as it renders many network-dependent services useless.
Common Troubleshooting for Blocked Ports in Mikrotik
When you’re managing a network and have blocked ports, it’s common to face issues where certain services or applications are not working as expected. Troubleshooting blocked ports in Mikrotik involves checking several factors to identify the cause of the problem and fixing it effectively.
Check the Firewall Rules
The first step in troubleshooting blocked ports is to review the firewall rules you’ve set up. In Mikrotik, the firewall is the most common reason for blocked ports. If a specific port is not working, you should check if there are any firewall rules that may have unintentionally blocked the port.
Go to the “IP” menu and then the “Firewall” tab in RouterOS, where you can view the list of active rules. Ensure that the rule blocking the port is necessary and not too broad, as it may also block other services that rely on the same port.
Verify the Correct Port Number
Sometimes, the issue might be as simple as a typo in the port number. Ensure that you have entered the correct port in the firewall rule. Double-check both the source and destination ports. If you have blocked multiple ports, ensure you didn’t accidentally miss the one you intended to block.
Test the Port from a Different Device
To isolate whether the issue is with the Mikrotik router or the device itself, try accessing the blocked port from another device or network. This can help you determine if the problem is specific to the router or if it affects multiple devices.
Check for NAT (Network Address Translation) Rules
If your Mikrotik router is behind another router or firewall, there may be NAT rules that are redirecting traffic to an incorrect destination. Check the NAT rules to ensure that they are correctly configured and not conflicting with the firewall rules you’ve set to block the port.
Review Logs for Errors
Mikrotik provides logs that can help you troubleshoot firewall issues. In the “Log” tab of the Mikrotik router, you can review any error messages related to firewall rules or blocked traffic. Look for messages that might indicate why a particular port is being blocked or if any other rules are interfering with the port.
Check for Connections on the Port
Use Mikrotik’s built-in tools to monitor traffic and see if there are any active connections on the blocked port. If you see unexpected connections or traffic on the port, it may indicate that another rule is overriding your blocking rule.
Test Using Telnet or Netcat
To verify if a port is truly blocked, use tools like “telnet” or “nc” (Netcat) from a remote device to check the status of the port. If the connection fails, the port is indeed blocked. If it succeeds, you may need to review your firewall configuration for possible conflicts.