Config generators
MikroTik RouterOS config generator
Generate a clean RouterOS 7 starting configuration for a MikroTik router in a home lab or small office: LAN bridge, internet by DHCP or PPPoE, DHCP server, DNS, NAT and a stateful firewall, with optional hardening of the management services.
RouterOS 7 script
# RouterOS 7 basic configuration — generated by runonprem.com
# Apply on a router reset with no default configuration; review every line first.
/system identity set name="router"
/interface bridge add name=bridge-lan comment="LAN"
/interface bridge port add bridge=bridge-lan interface=ether2
/interface bridge port add bridge=bridge-lan interface=ether3
/interface bridge port add bridge=bridge-lan interface=ether4
/interface bridge port add bridge=bridge-lan interface=ether5
/interface list add name=WAN
/interface list add name=LAN
/interface list member add list=LAN interface=bridge-lan
/interface list member add list=WAN interface=ether1
/ip dhcp-client add interface=ether1 use-peer-dns=no add-default-route=yes disabled=no
/ip address add address=192.168.88.1/24 interface=bridge-lan network=192.168.88.0
/ip pool add name=lan-pool ranges=192.168.88.10-192.168.88.254
/ip dhcp-server add name=lan-dhcp interface=bridge-lan address-pool=lan-pool lease-time=1d
/ip dhcp-server network add address=192.168.88.0/24 gateway=192.168.88.1 dns-server=192.168.88.1
/ip dns set servers=1.1.1.1,9.9.9.9 allow-remote-requests=yes
/ip firewall nat add chain=srcnat out-interface-list=WAN action=masquerade comment="LAN to internet"
/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 protocol=icmp comment="accept ICMP"
add chain=input action=accept in-interface-list=LAN comment="accept from LAN"
add chain=input action=drop comment="drop all other input"
add chain=forward action=fasttrack-connection connection-state=established,related hw-offload=yes comment="fasttrack"
add chain=forward action=accept connection-state=established,related,untracked comment="accept established, related, untracked"
add chain=forward action=drop connection-state=invalid comment="drop invalid"
add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN comment="drop new from WAN unless port-forwarded"
/ip service set telnet disabled=yes
/ip service set ftp disabled=yes
/ip service set www disabled=yes
/ip service set api disabled=yes
/ip service set api-ssl disabled=yes
/tool mac-server set allowed-interface-list=LAN
/tool mac-server mac-winbox set allowed-interface-list=LAN
/ip neighbor discovery-settings set discover-interface-list=LAN
How to use it
- Back up the current configuration (/export file=backup) and reset the router without the default configuration: /system reset-configuration no-defaults=yes.
- Choose the WAN port and connection type. For PPPoE, enter the credentials from your ISP — the password is used only in your browser and never added to the share link.
- List the LAN ports for the bridge, the router LAN address and where the DHCP pool should start.
- Connect by MAC address with Winbox or by serial console (an IP session may drop while the bridge is built), paste the script into the terminal or import the .rsc file, then test internet access and the firewall.
Formula and method
LAN bridge-lan with the listed ports, interface list LAN WAN DHCP client on the WAN port, or pppoe-out1 on it; interface list WAN DHCP pool from host N to the last host of the LAN subnet; router = gateway + DNS NAT srcnat out-interface-list=WAN action=masquerade input accept established/related/untracked, drop invalid, accept ICMP, accept LAN, drop rest forward fasttrack + accept established/related, drop invalid, drop new from WAN unless dst-NAT
- Review the script before applying it. Use Safe Mode (Ctrl+X in the terminal) so changes roll back if you lose the connection.
- The rules follow the structure of MikroTik’s own default firewall. Port forwards (dst-nat) you add later pass the last forward rule automatically.
- IPv6 is not configured by this script; RouterOS 7 drops nothing for IPv6 until you add IPv6 firewall rules, so add them before enabling IPv6 on the WAN.
Worked example
With WAN on ether1 by DHCP, ether2–ether5 in the LAN bridge and the router at 192.168.88.1/24 with the pool starting at host 10, the script adds /ip pool add name=lan-pool ranges=192.168.88.10-192.168.88.254, a DHCP server on bridge-lan handing out gateway and DNS 192.168.88.1, a DHCP client on ether1 and masquerade for everything leaving the WAN list.
FAQ
Does this work on RouterOS 6?
Most commands are the same, but the script targets RouterOS 7 (for example hw-offload on the fasttrack rule). Upgrade to the current long-term or stable release first.
Why disable telnet, FTP, www and the API?
They are plain-text or rarely needed management services. With hardening on, SSH and Winbox remain; MAC Winbox and neighbour discovery are limited to the LAN interface list.
Is the PPPoE password stored anywhere?
No. It is only used to build the script in your browser and is not written to the URL. It does appear in the generated script, so keep that file private.
Related tools
- VLAN & subnet planner — Give every VLAN the right-sized IPv4 subnet from one block, with gateway and DHCP pool, allocated without overlaps.
- WireGuard config generator with QR codes — Create WireGuard server and peer configs with keys generated in your browser, plus QR codes for phones.
- IPv4 subnet (CIDR) calculator — Network, broadcast, netmask, wildcard and host range of any IPv4 CIDR, and how to split it into smaller subnets.
Formulas reviewed November 27, 2026 by Novian · runs entirely in your browser · methodology