RouterOS build template
A build template checks that a router was set up the way you set up every router. It is a starting point, not a security check. It comes from the routeros-build-template policy template.
Every example on this page was checked with rConfig Pro's policy engine on Each of the 20 configs below was run through rConfig Pro’s evaluator with the rule above it, and gave the result shown. The configs are sanitised excerpts of the sample configs that come with the template. A card marked changed has one line edited to show a failure.
All the rules come from routeros-build-template.policy in the policy templates (v1.5.0). Import the whole file with Import Templates (see importing a policy template), or copy one rule into your own definition. The MikroTik RouterOS templates page lists the file’s known limitations. Run the rules against the output of /export.
| Rule | Method | Since |
|---|---|---|
| Identity is set | evaluate_block |
8.3.0 |
| Timezone | evaluate_block |
8.3.0 |
| Unused services off | evaluate_block |
8.3.0 |
| LAN bridge | evaluate_block |
8.3.0 |
| DHCP server | evaluate_block |
8.3.0 |
| DNS servers | evaluate_block |
8.3.0 |
| Source NAT | evaluate_block |
8.3.0 |
| Firewall filter | evaluate_block |
8.3.0 |
| NTP client | evaluate_block |
8.3.0 |
| Remote logging | evaluate_block |
8.3.0 |
Identity is set
The identity is the router’s name. It shows in Winbox, in logs and in rConfig. This rule passes when /system identity has a set name= line, with any name.
// Identity is set (/system identity, set name=)#[evaluate_block]all: - regex: '/^\/system identity\n(?:(?!\/)[^\n]*\n)*?^set(?![^\s\\])(?=(?:[^\n]|\\\n)*? name=[^\s\\]+(?![^\s\\]))/m'/system identityset name=office-edge01Why: The router has a name.
/system clockset time-zone-name=Europe/Dublin/system ntp clientset enabled=yesWhy: There is no /system identity section, so the router still has its factory name.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
Timezone
Logs are easier to read in local time. This rule needs set time-zone-name=Europe/Dublin under /system clock. Change it to your own timezone.
// Timezone is Europe/Dublin (/system clock, set time-zone-name=Europe/Dublin)#[evaluate_block]all: - regex: '/^\/system clock\n(?:(?!\/)[^\n]*\n)*?^set(?![^\s\\])(?=(?:[^\n]|\\\n)*? time-zone-name=Europe\/Dublin(?![^\s\\]))/m'/system clockset time-zone-name=Europe/DublinWhy: The timezone is Europe/Dublin.
/system clockset time-zone-name=Europe/LondonWhy: Europe/London is not the timezone in the rule.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
Unused services off
Telnet, FTP and plain web access send passwords in clear text, and the API is one more way in. This rule needs telnet, ftp, www, www-ssl, api and api-ssl all set to disabled=yes, and strong crypto on for SSH. One missing line fails the rule.
// Telnet, FTP, www, www-ssl, API and API-SSL services are disabled and SSH strong crypto is on#[evaluate_block]all: - regex: '/^\/ip service\n(?:(?!\/)[^\n]*\n)*?^set telnet(?![^\s\\])(?=(?:[^\n]|\\\n)*? disabled=yes(?![^\s\\]))/m' - regex: '/^\/ip service\n(?:(?!\/)[^\n]*\n)*?^set ftp(?![^\s\\])(?=(?:[^\n]|\\\n)*? disabled=yes(?![^\s\\]))/m' - regex: '/^\/ip service\n(?:(?!\/)[^\n]*\n)*?^set www(?![^\s\\])(?=(?:[^\n]|\\\n)*? disabled=yes(?![^\s\\]))/m' - regex: '/^\/ip service\n(?:(?!\/)[^\n]*\n)*?^set www-ssl(?![^\s\\])(?=(?:[^\n]|\\\n)*? disabled=yes(?![^\s\\]))/m' - regex: '/^\/ip service\n(?:(?!\/)[^\n]*\n)*?^set api(?![^\s\\])(?=(?:[^\n]|\\\n)*? disabled=yes(?![^\s\\]))/m' - regex: '/^\/ip service\n(?:(?!\/)[^\n]*\n)*?^set api-ssl(?![^\s\\])(?=(?:[^\n]|\\\n)*? disabled=yes(?![^\s\\]))/m' - regex: '/^\/ip ssh\n(?:(?!\/)[^\n]*\n)*?^set(?![^\s\\])(?=(?:[^\n]|\\\n)*? strong-crypto=yes(?![^\s\\]))/m'/ip serviceset telnet disabled=yesset ftp disabled=yesset www disabled=yesset ssh port=22set www-ssl disabled=yesset api disabled=yesset api-ssl disabled=yes/ip sshset strong-crypto=yesWhy: Six services are off and SSH uses strong crypto.
/ip serviceset telnet disabled=yesset ftp disabled=yesset www disabled=yesset ssh port=22set www-ssl disabled=yesset api disabled=yes/ip sshset strong-crypto=yesWhy: There is no set api-ssl disabled=yes line, so API-SSL is still on.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
LAN bridge
The LAN ports sit in one bridge with one address. This rule needs a bridge called bridge1, ether1 in that bridge, and a /24 address on it.
// LAN bridge bridge1 holds ether1 and has a /24 address#[evaluate_block]all: - regex: '/^\/interface bridge\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? name=bridge1(?![^\s\\]))/m' - regex: '/^\/interface bridge port\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? bridge=bridge1(?![^\s\\]))(?=(?:[^\n]|\\\n)*? interface=ether1(?![^\s\\]))/m' - regex: '/^\/ip address\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? address=[^\s\\]+\/24(?![^\s\\]))(?=(?:[^\n]|\\\n)*? interface=bridge1(?![^\s\\]))/m'/interface bridgeadd name=bridge1/interface bridge portadd bridge=bridge1 interface=ether1/ip addressadd address=192.168.88.1/24 interface=bridge1 network=192.168.88.0Why: bridge1 holds ether1 and has a /24 address.
/interface bridgeadd comment="Management" name=bridge-mgmt/interface bridge portadd bridge=bridge-mgmt interface=ether1/ip addressadd address=192.0.2.4/24 comment="Management" interface=bridge-mgmt network=192.0.2.0Why: The bridge is called bridge-mgmt, not bridge1.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
DHCP server
Devices on the LAN get their addresses from the router. This rule needs a pool called dhcp_pool from .10 to .254, a server called dhcp1 on bridge1 using that pool, and a /24 network with a .1 gateway.
// DHCP server dhcp1 on bridge1 uses pool dhcp_pool (.10 to .254) and a /24 network with a .1 gateway#[evaluate_block]all: - regex: '/^\/ip pool\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? name=dhcp_pool(?![^\s\\]))(?=(?:[^\n]|\\\n)*? ranges=[^\s\\]*\.10-[^\s\\]*\.254(?![^\s\\]))/m' - regex: '/^\/ip dhcp-server\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? address-pool=dhcp_pool(?![^\s\\]))(?=(?:[^\n]|\\\n)*? interface=bridge1(?![^\s\\]))(?=(?:[^\n]|\\\n)*? name=dhcp1(?![^\s\\]))/m' - regex: '/^\/ip dhcp-server network\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? address=[^\s\\]*\.0\/24(?![^\s\\]))(?=(?:[^\n]|\\\n)*? gateway=[^\s\\]*\.1(?![^\s\\]))/m'/ip pooladd name=dhcp_pool ranges=192.168.88.10-192.168.88.254/ip dhcp-serveradd address-pool=dhcp_pool interface=bridge1 name=dhcp1/ip dhcp-server networkadd address=192.168.88.0/24 gateway=192.168.88.1Why: The pool, the server and the network all match.
/ip pooladd name=lan-pool ranges=198.51.100.200-198.51.100.250/ip dhcp-serveradd address-pool=lan-pool interface=bridge-lan lease-time=1d name=lan-dhcp/ip dhcp-server networkadd address=198.51.100.128/25 dns-server=198.51.100.129 gateway=198.51.100.129Why: The names, range and network size are all different from the template.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
DNS servers
The router answers DNS for the LAN and forwards to set servers. This rule needs allow-remote-requests=yes and servers=8.8.8.8,8.8.4.4 on the /ip dns line, in any order.
// DNS servers are 8.8.8.8 and 8.8.4.4 with remote requests allowed (/ip dns)#[evaluate_block]all: - regex: '/^\/ip dns\n(?:(?!\/)[^\n]*\n)*?^set(?![^\s\\])(?=(?:[^\n]|\\\n)*? allow-remote-requests=yes(?![^\s\\]))(?=(?:[^\n]|\\\n)*? servers=8\.8\.8\.8,8\.8\.4\.4(?![^\s\\]))/m'/ip dnsset allow-remote-requests=yes servers=8.8.8.8,8.8.4.4Why: Remote requests are on and both servers are set.
/ip dnsset servers=192.0.2.53,192.0.2.54Why: Different servers, and remote requests are not turned on.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
Source NAT
LAN devices reach the internet through the router’s WAN address. This rule needs a srcnat rule that masquerades out of ether1. The arguments can be in any order.
// Source NAT masquerades out ether1 (/ip firewall nat)#[evaluate_block]all: - regex: '/^\/ip firewall nat\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=masquerade(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=srcnat(?![^\s\\]))(?=(?:[^\n]|\\\n)*? out-interface=ether1(?![^\s\\]))/m'/ip firewall natadd chain=srcnat out-interface=ether1 action=masqueradeWhy: action=masquerade comes last here, and it still matches.
/ip firewall natadd action=masquerade chain=srcnat comment="Management to internet" out-interface=sfp-sfpplus1 src-address=192.0.2.0/24Why: It masquerades out of sfp-sfpplus1, not ether1.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
Firewall filter
The firewall lets in replies and LAN traffic and drops everything else. This rule checks nine filter lines. The two catch-all drop lines must be exactly add action=drop chain=input and add action=drop chain=forward, with nothing else on them.
// Input and forward firewall filter rules accept established, related and LAN traffic and drop the rest#[evaluate_block]all: - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=accept(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=input(?![^\s\\]))(?=(?:[^\n]|\\\n)*? connection-state=established,related(?![^\s\\]))/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=drop(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=input(?![^\s\\]))(?=(?:[^\n]|\\\n)*? connection-state=invalid(?![^\s\\]))/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=accept(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=input(?![^\s\\]))(?=(?:[^\n]|\\\n)*? protocol=icmp(?![^\s\\]))/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=accept(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=input(?![^\s\\]))(?=(?:[^\n]|\\\n)*? src-address=192\.168\.88\.0\/24(?![^\s\\]))/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\]) action=drop chain=input$/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=accept(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=forward(?![^\s\\]))(?=(?:[^\n]|\\\n)*? connection-state=established,related(?![^\s\\]))/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=drop(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=forward(?![^\s\\]))(?=(?:[^\n]|\\\n)*? connection-state=invalid(?![^\s\\]))/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=accept(?![^\s\\]))(?=(?:[^\n]|\\\n)*? chain=forward(?![^\s\\]))(?=(?:[^\n]|\\\n)*? connection-state=new(?![^\s\\]))(?=(?:[^\n]|\\\n)*? in-interface=bridge1(?![^\s\\]))(?=(?:[^\n]|\\\n)*? src-address=192\.168\.88\.0\/24(?![^\s\\]))/m' - regex: '/^\/ip firewall filter\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\]) action=drop chain=forward$/m'/ip firewall filteradd action=accept chain=input connection-state=established,relatedadd action=drop chain=input connection-state=invalidadd action=accept chain=input protocol=icmpadd action=accept chain=input src-address=192.168.88.0/24add action=drop chain=inputadd action=accept chain=forward connection-state=established,relatedadd action=drop chain=forward connection-state=invalidadd action=accept chain=forward comment="LAN to anywhere" connection-state=new \ in-interface=bridge1 src-address=192.168.88.0/24add action=drop chain=forwardWhy: All nine lines are there. The long line wrapped with a backslash still matches.
/ip firewall filteradd action=accept chain=input comment="Accept established" connection-state=established,relatedadd action=drop chain=input comment="Drop invalid" connection-state=invalidadd action=accept chain=input comment="Accept ICMP" protocol=icmpadd action=accept chain=input comment="Management" src-address=192.0.2.0/24add action=drop chain=input comment="Drop everything else from the internet" in-interface=sfp-sfpplus1add action=accept chain=forward comment="Accept established" connection-state=established,relatedadd action=drop chain=forward comment="Drop invalid" connection-state=invalidadd action=accept chain=forward comment="Public range behind the firewalls" dst-address=203.0.113.0/29add action=drop chain=forward comment="Drop everything else from the internet" in-interface=sfp-sfpplus1Why: The drop lines have extra arguments, and the LAN is not 192.168.88.0/24.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
NTP client
The router gets its time from set servers. This rule accepts the RouterOS 6 form (both servers on the set line) or the RouterOS 7 form (one add address= line per server).
// NTP client is enabled with servers 216.239.35.0 and 216.239.36.0 (RouterOS 6 or 7 form)#[evaluate_block]any: - regex: '/^\/system ntp client\n(?:(?!\/)[^\n]*\n)*?^set(?![^\s\\])(?=(?:[^\n]|\\\n)*? enabled=yes(?![^\s\\]))(?=(?:[^\n]|\\\n)*? primary-ntp=216\.239\.35\.0(?![^\s\\]))(?=(?:[^\n]|\\\n)*? secondary-ntp=216\.239\.36\.0(?![^\s\\]))/m' - all: - regex: '/^\/system ntp client\n(?:(?!\/)[^\n]*\n)*?^set(?![^\s\\])(?=(?:[^\n]|\\\n)*? enabled=yes(?![^\s\\]))/m' - regex: '/^\/system ntp client servers\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? address=216\.239\.35\.0(?![^\s\\]))/m' - regex: '/^\/system ntp client servers\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? address=216\.239\.36\.0(?![^\s\\]))/m'/system ntp clientset enabled=yes/system ntp client serversadd address=216.239.35.0add address=216.239.36.0Why: The RouterOS 7 form, with both servers.
/system ntp clientset enabled=yes/system ntp client serversadd address=192.0.2.1add address=192.0.2.2Why: NTP is on, but with different servers.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
Remote logging
Logs are sent to a syslog server so they are not lost. This rule needs a remote action to 192.168.88.2, and info, warning and error topics sent to the action called remote.
// Info, warning and error topics log to a remote action at 192.168.88.2 (/system logging)#[evaluate_block]all: - regex: '/^\/system logging action\n(?:(?!\/)[^\n]*\n)*?^(?:set|add)(?![^\s\\])(?=(?:[^\n]|\\\n)*? remote=192\.168\.88\.2(?![^\s\\]))/m' - regex: '/^\/system logging\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=remote(?![^\s\\]))(?=(?:[^\n]|\\\n)*? topics=info(?![^\s\\]))/m' - regex: '/^\/system logging\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=remote(?![^\s\\]))(?=(?:[^\n]|\\\n)*? topics=warning(?![^\s\\]))/m' - regex: '/^\/system logging\n(?:(?!\/)[^\n]*\n)*?^add(?![^\s\\])(?=(?:[^\n]|\\\n)*? action=remote(?![^\s\\]))(?=(?:[^\n]|\\\n)*? topics=error(?![^\s\\]))/m'/system logging actionset 3 remote=192.168.88.2/system loggingadd action=remote topics=infoadd action=remote topics=warningadd action=remote topics=errorWhy: The remote action and all three topics are set.
/system logging actionadd name=syslog remote=192.0.2.50 target=remote/system loggingadd action=syslog topics=infoadd action=syslog topics=warningadd action=syslog topics=criticalWhy: A different server and action name, and critical instead of error.
Expected result in rConfig, with this rule as the only rule in a definition:
| Config | Rule result | Overall result |
|---|---|---|
| Passing config | pass | PASS |
| Failing config | fail | FAIL |
Framework mapping. The rule provides evidence towards these controls. It does not certify anything.
| Framework | Reference |
|---|---|
| None recorded | See Compliance frameworks |
Tested with: sample excerpts from RouterOS 7.15.3 (synthetic). Minimum rConfig 8.3.0 (evaluate_block). Editions: Pro, Vector, Enterprise.
Related reference
- MikroTik RouterOS policy templates: every rule in
routeros-build-template.policy, its references and known limitations. - Policy Definitions: the definition file format and every method.
- Policy Assignments: run a definition against your devices.
- Policy Compliance Results: read the pass and fail results.