Securing your router
CLI reference:/ip/firewall/filter/ipv6/firewall/filter/user/user/settings/tool/mac-server/ip/neighbor/discovery-settings/tool/bandwidth-server/ip/dns/ip/smb/ip/tftp/disk/settings/ip/media/ip/cloud/ip/ssh/ip/service/interface/lcd
The following steps are recommendations on how to additionally protect your device with already configured strong firewall rules.
RouterOS Version
Start by upgrading your RouterOS version. Some older releases have had certain weaknesses or vulnerabilities that have been fixed. Keep your device up to date to ensure it is secure. To upgrade, select Check for Updates in WinBox or WebFig. It is recommended to follow announcements on our Security Announcements Blog to stay informed about any new security issues.
Access Username
A new router has one user, admin, in the built-in full group. The router keeps at least one enabled user with full rights, so create your own account first:
/user/add name=myname group=full password="!={Ba3N!40TyX+GvKBz?jTLIUcx/,"
Log in as myname and confirm the login works. Then delete admin, so the most common username is not a login target:
/user/remove [find name=admin]
RouterOS refuses the last enabled user in the full group, with the user is last one with full access permissions.
Access password
MikroTik routers require password configuration. Use a password generator tool to create secure and non-repeating passwords. A secure password:
- Minimum 12 characters.
- Include numbers, symbols, capital and lowercase letters.
- Is not a dictionary word or a combination of dictionary words.
- In a quoted password, escape
",\and$with a backslash (\$). An unescaped$starts a variable name: the router replaces it and the name after it with the variable's value, usually nothing, and the password silently ends up shorter.
Enforce the length and character categories on the router, so a weak password is rejected:
/user/settings/set minimum-password-length=12 minimum-categories=3
User accounts and groups
Create one account per administrator instead of sharing a single account, and give each account a custom group with only the required policies. The built-in read group can reboot the router and see sensitive configuration, so it is not a safe account for monitoring. For key-based login, import each administrator's public SSH key. When a user has a key assigned, SSH password login is disabled for that user. See User.
Securing access to the device
The pre-configured firewall of MikroTik home and office routers blocks all management access from the WAN (internet-facing) interface. This is intentional — do not remove these rules unless you fully understand the consequences.
Check the firewall first. A router installed without the default configuration, such as CHR, x86, or a device installed with Netinstall and no defaults, has no firewall at all, and its management services listen on every interface. Run /ip/firewall/filter/print. An empty list means nothing filters input traffic, and you need the complete input chain from Build an IPv4 firewall.
Network devices with management interfaces open to the internet are constantly scanned and targeted by automated attacks. Exposing WinBox, SSH, or other management services directly to the internet can lead to:
- Brute-force attacks against login credentials.
- Exploitation of known vulnerabilities in unpatched RouterOS versions.
- Complete device compromise — attackers can intercept traffic, redirect DNS, install malware, or use the router as a proxy for further attacks.
If you need remote access to your device, use a VPN such as WireGuard to create an encrypted tunnel. This keeps management traffic off the public internet entirely.
Remote access from the internet (advanced)
Do not open WinBox, WebFig or SSH to the internet. Expose only the port of one authenticated service, for example WireGuard, and manage the router through its tunnel. WireGuard answers only a peer with a configured key, so the open UDP port stays silent for everyone else. The key and peer configuration is in RoadWarrior WireGuard tunnel.
The rules on this page are examples. They open WireGuard on UDP port 13231. Replace the protocol and the port with those of the service you expose.
On a router with the default configuration, everything from outside the LAN is already dropped. Add one accept rule in front of that rule:
/ip/firewall/filter
add chain=input action=accept \
in-interface-list=WAN protocol=udp dst-port=13231 \
comment="allow WireGuard" \
place-before=[find comment="defconf: drop all not coming from LAN"]
With IPv6, add the same rule to /ipv6/firewall/filter, before the input rule defconf: drop everything else not coming from LAN. An IPv4 rule does not filter IPv6 traffic:
/ipv6/firewall/filter
add chain=input action=accept \
in-interface-list=WAN protocol=udp dst-port=13231 \
comment="allow WireGuard" \
place-before=[find chain=input comment="defconf: drop everything else not coming from LAN"]
A router without the default configuration has no input rules at all. The complete chain then needs the service accept plus the drops around it:
/ip/firewall/filter
add chain=input action=accept \
connection-state=established,related,untracked \
comment="accept established,related,untracked"
add chain=input action=drop \
connection-state=invalid \
comment="drop invalid"
add chain=input action=accept \
in-interface=ether1 protocol=icmp \
comment="accept ICMP"
add chain=input action=accept \
in-interface=ether1 protocol=udp dst-port=13231 \
comment="allow WireGuard"
add chain=input action=drop \
in-interface=ether1 \
comment="block everything else"
After the tunnel is up, connect WinBox or SSH to the tunnel address. The management services stay closed on the WAN interface. To allow management over the tunnel only, accept the tunnel subnet in the input chain:
/ip/firewall/filter
add chain=input action=accept \
in-interface=wireguard1 protocol=tcp dst-port=22,8291 \
comment="management over WireGuard" \
place-before=[find comment="defconf: drop all not coming from LAN"]
If the public interface is PPPoE, LTE, or another interface type, in-interface should be set accordingly. If you select the wrong interface, you may lose access to the device.
Before you change firewall rules or service addresses over a remote connection, enable Safe Mode with Control+X. If the connection drops, the router reverts the changes.
If you open remote access, you must also:
- Keep private keys secret and give each device its own key pair.
- Remove peers you no longer use.
- Restrict access to specific source addresses where possible.
- Keep RouterOS updated to the latest stable release.
- Monitor logs for unexpected WireGuard peers and failed logins.
You can also limit a specific user account to certain source addresses with the Allowed Address property:
/user/set [find name=myname] address=192.168.88.0/24
The list takes IPv4 and IPv6 prefixes. A list with only IPv4 prefixes refuses all IPv6 clients, so add the IPv6 prefix your administrator network uses, for example address=192.168.88.0/24,2001:db8:88::/64.
RouterOS MAC-access
RouterOS includes built-in feature options that provide convenient management access to network devices. The IP firewall does not stop them, because they work below IP. Disable MAC-Telnet, MAC-WinBox, and MAC-Ping in production networks:
/tool/mac-server/set allowed-interface-list=none
/tool/mac-server/mac-winbox/set allowed-interface-list=none
/tool/mac-server/ping/set enabled=no
Without the default configuration, these services accept connections on all interfaces. A device with the default configuration limits MAC Telnet and MAC WinBox to the LAN interface list. MAC ping has no interface list, only the switch.
Neighbor Discovery
The MikroTik Neighbor Discovery protocol is used to discover and identify other MikroTik routers on the network. It advertises the router identity, MAC address and software version to every device on the segment. To disable Neighbor Discovery on all interfaces, use the following command:
/ip/neighbor/discovery-settings/set discover-interface-list=none
To keep discovery on the LAN only, set the list to your LAN interface list instead of none.
Bandwidth server
The bandwidth server is used to test throughput between two MikroTik routers. Disable it in the production environment:
/tool/bandwidth-server/set enabled=no
DNS Cache
DNS cache improves performance by storing resolved DNS query results locally on the router, reducing the time needed to resolve DNS requests from client devices to remote servers.
When the router is the DNS server for your network, as in the default configurations of home and office routers, keep allow-remote-requests=yes so that local devices can use it. The default firewall drops DNS queries from the internet. If you use your own firewall rules, drop these queries as well. See Use the router as the DNS server for your network.
If the router does not need to answer DNS queries from other devices—for example, if another device on your network handles DNS—turn off remote requests. The router then resolves names only for itself, and it cannot answer DNS queries from the internet even if a firewall rule lets them through:
/ip/dns/set allow-remote-requests=no
Send the router's own queries to a trusted upstream server over HTTPS, so the queries leave the router encrypted and cannot be read or altered on the path to the internet:
/ip/dns/set use-doh-server=https://cloudflare-dns.com/dns-query verify-doh-cert=yes
The router looks up the DoH server name through its current servers, so leave at least one working server in the list. Details are in DNS over HTTPS.
Additional Services
The SMB server is auto and starts as soon as a share exists in /ip/smb/shares, so turn it off unless you serve files:
/ip/smb/set enabled=no
The router registers a MikroTik cloud DNS name only while Back To Home is enabled. Stop it from also setting its clock from the cloud:
/ip/cloud/set update-time=no
The TFTP server serves the entries in /ip/tftp. Keep the list empty unless you need it.
The default configuration of some routers shares disks and media automatically. Where these menus exist, turn it off unless you need it:
/disk/settings/set auto-smb-sharing=no auto-media-sharing=no auto-media-interface=none
/ip/media/print
Management service ports
/ip/service/print lists the services and their ports. Disable everything you do not use, including the plain-text web and API ports:
/ip/service/disable telnet,ftp,www,api
For web access and the API, use only the TLS variants www-ssl (443) and api-ssl (8729). Never enable www (80) or api (8728) next to them, otherwise the same login also travels unencrypted. The TLS variants are disabled and have no certificate, so browsers cannot connect, and the connection does not prove the router identity. Import a certificate, set it with certificate=, enable the service, and allow only TLS 1.2 and later:
/ip/service/set www-ssl certificate=mycert tls-version=min-1.2 disabled=no
/ip/service/set api-ssl certificate=mycert tls-version=min-1.2 disabled=no
Changing the default SSH port offers little against scanners, which try every port. Firewall rules are the control that matters.
Each service can also be restricted to specific source addresses, although enforcing access control with firewall rules (above) is preferred, as it prevents the connection from reaching the service at all:
/ip/service/set winbox available-from=192.168.88.0/24
available-from accepts IPv4 and IPv6 prefixes. A client from another address can still open the TCP connection and the router closes it, so the port stays visible.
More Secure SSH Access
The SSH server uses an ed25519 host key and, by default, also offers 128-bit, CBC and 3DES ciphers, the SHA-1 and MD5 MACs, SHA-1 key exchanges, the none cipher and the ssh-rsa host key signature. The following command removes all of them, offers RSA host keys only with the rsa-sha2-512 and rsa-sha2-256 signatures, and grows the Diffie-Hellman group from 1024 to 2048 bits:
/ip/ssh/set strong-crypto=yes
Older SSH clients that do not offer the stronger algorithms then fail to connect. For access control that does not depend on the client, import your public key first, as described in Log in with a public key, and then turn off password logins:
/ip/ssh/set password-authentication=no
Router interface
Ethernet/SFP interfaces
It is good practice to disable all unused interfaces on your router to decrease unauthorized access to your router:
/interface/print
/interface/set [find name=ether5] disabled=yes
Replace ether5 with the name of the unused interface.
LCD
Some RouterBOARD devices include an LCD module for displaying system information. To secure the LCD, set a PIN code:
/lcd/pin/set pin-number=3659 hide-pin-number=yes
Alternatively, you can disable the LCD entirely:
/lcd/set enabled=no