RouterOS configuration

MikroTik Basic Internet Setup from Scratch (DHCP, NAT, DNS, Firewall)

Configure a new MikroTik router for internet from a blank configuration: WAN and LAN, DHCP server, DNS, NAT masquerade and a safe basic firewall, step by step.

Commands in this article follow RouterOS v7 documentation but have not yet been marked as lab-tested on this site. Always test changes in a lab or maintenance window and keep a backup.

Problem

You have a MikroTik router with no configuration (or you removed the default one) and you need to give internet to a LAN step by step, the way it is taught in MTCNA.

Symptoms

  • PCs on the LAN get no IP address.
  • The router has internet, but the LAN does not.
  • The router is reachable from the internet on WinBox or DNS.

Likely causes

A working setup needs six parts: a WAN address, a LAN address, a DHCP server, DNS, NAT and a firewall. Missing any one of them causes the symptoms above.

Prerequisites

  • WAN cable from the ISP in ether1, LAN devices on ether2-ether5.
  • The ISP connection type: DHCP, static IP or PPPoE. This example uses DHCP. For PPPoE see MikroTik PPPoE client setup.

Solution (WinBox / CLI)

1. Interface lists and LAN bridge

RouterOS CLI
/interface list add name=WAN
/interface list add name=LAN
/interface bridge add name=bridge-lan
/interface bridge port add bridge=bridge-lan interface=ether2
/interface bridge port add bridge=bridge-lan interface=ether3
/interface list member add list=WAN interface=ether1
/interface list member add list=LAN interface=bridge-lan

2. WAN and LAN addresses

RouterOS CLI
/ip dhcp-client add interface=ether1 disabled=no
/ip address add address=192.168.88.1/24 interface=bridge-lan

3. DHCP server and DNS

RouterOS CLI
/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 disabled=no
/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=8.8.8.8,1.1.1.1 allow-remote-requests=yes

4. NAT

RouterOS CLI
/ip firewall nat add chain=srcnat out-interface-list=WAN action=masquerade

5. Basic firewall (the same idea as MikroTik's default configuration):

RouterOS CLI
/ip firewall filter
add chain=input action=accept connection-state=established,related,untracked
add chain=input action=drop connection-state=invalid
add chain=input action=accept protocol=icmp
add chain=input action=drop in-interface-list=!LAN
add chain=forward action=accept connection-state=established,related,untracked
add chain=forward action=drop connection-state=invalid
add chain=forward action=drop connection-state=new connection-nat-state=!dstnat in-interface-list=WAN

Warning: Add the firewall while connected from the LAN side, or use Safe Mode in WinBox, so you do not lock yourself out.

Verification

  • /ip dhcp-client print shows bound with an address from the ISP.
  • A LAN PC gets an address from 192.168.88.10-254 and can open websites.
  • /ping 8.8.8.8 and /ping google.com work from the router.

Common errors

  • DHCP server on the wrong interface (ether2 instead of the bridge).
  • Forgot NAT: the router has internet, LAN clients do not.
  • allow-remote-requests=yes without the input firewall: your router becomes an open DNS server.

Rollback

Remove the parts you added in reverse order, or reset to the default configuration with /system reset-configuration. Export first with /export file=basic-setup so you can compare later.

Go deeper in class

This topic is covered hands-on in MTCNA — MikroTik Certified Network Associate.

View MTCNA
WhatsApp