Categories

Mikrotik DUAL WAN Configuration for 2 ISP Combination

Configuration Windows

  • Interface List
  • Route List
  • Address List
  • DHCP Client

Rename the Interfaces

  • Ether1 to ether1-wan1
  • Ether2 to ether2-wan2
  • Ether4 to ether4-lan

Configure Interfaces with IP Addresses

  • IP > Address: 192.168.88.1/24, Interface: ether4-lan
  • IP > DHCP Client: Add (+) New DHCP client, Interface: ether1-wan1 Add Default Route: no, , apply script under Advanced > Scripts:
{
    :local rmark "to_wan1"
    :local count [/ip route print count-only where comment="to_wan1"]
    :if ($bound=1) do={
        :if ($count = 0) do={
            /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping routing-mark=to_wan1 comment="to_wan1"
            /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping comment="to_wan1"
        } else={
            :if ($count = 1) do={
                :local test [/ip route find where comment="to_wan1"]
                :if ([/ip route get $test gateway] != $"gateway-address") do={
                    /ip route set $test gateway=$"gateway-address"
                }
            } else={
                :error "Multiple routes found"
            }
        }
    } else={
        /ip route remove [find comment="to_wan1"]
    }
}
  • IP > DHCP Client: Add (+) New DHCP client, Interface: ether2-wan2 Add Default Route: no, , apply script under Advanced > Scripts:
{
    :local rmark "to_wan2"
    :local count [/ip route print count-only where comment="to_wan2"]
    :if ($bound=1) do={
        :if ($count = 0) do={
            /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping routing-mark=to_wan1 comment="to_wan2"
            /ip route add distance=1 gateway=$"gateway-address" check-gateway=ping comment="to_wan2"
        } else={
            :if ($count = 1) do={
                :local test [/ip route find where comment="to_wan2"]
                :if ([/ip route get $test gateway] != $"gateway-address") do={
                    /ip route set $test gateway=$"gateway-address"
                }
            } else={
                :error "Multiple routes found"
            }
        }
    } else={
        /ip route remove [find comment="to_wan2"]
    }
}

Configure DHCP on LAN

  • IP > DHCP Server
  • DHCP Server Interface: ether4-lan
  • Next > Gateway for DHCP Network: 192.168.88.1
  • Next > Addresses to Give: 192.168.88.10-192.168.88.254
  • Next > DNS Servers: 8.8.8.8; 8.4.4.4
  • Next > Next

Configure NAT: IP > Fiirewall:

  • NAT > +
  • General: chain: srcnat, Src Address: 192.168.88.0/24, Out Interface: ether1-wan1
  • Action: masquerade
  • Apply; OK
  • NAT > +
  • General: chain: srcnat, Src Address: 192.168.88.0/24, Out Interface: ether2-wan2
  • Action: masquerade
  • Apply; OK

Configure Mangle: IP > Firewall :

  • Mangle > +
  • General: chain: prerouting, In Interface: ether1-wan1
  • Action: accept
  • Apply; OK
  • Mangle > +
  • General: chain: prerouting, In Interface: ether2-wan2
  • Action: accept
  • Apply; OK

Configure Mangle Marking Connection: IP > Firewall :

  • Mangle > +
  • General: chain: prerouting, Src Address: 192.168.88.0/24
  • Advanced: Per Connection Classifier: both addresses and ports:2/0
  • Action: mark connection, New Connection Mark: wan1_conn, Passthrough: checked
  • Extra: Dst Address Type: local, Invert: checked
  • Apply; OK
  • Mangle > +
  • General: chain: prerouting, Src Address: 192.168.88.0/24
  • Advanced: Per Connection Classifier: both addresses and ports:2/1
  • Action: mark connection, New Connection Mark: wan2_conn, Passthrough: checked
  • Extra: Dst Address Type: local, Invert: checked
  • Apply; OK

Mark Routing

  • Mangle > +
  • General: chain: prerouting, Src Address: 192.168.88.0/24, Connection Mask: wan1_conn
  • Action: mark routing, New Routing Mark: to_wan1, Passthrough: checked
  • Apply; OK
  • Mangle > +
  • General: chain: prerouting, Src Address: 192.168.88.0/24,, Connection Mask: wan2_conn
  • Action: mark routing, New Routing Mark: to_wan2, Passthrough: checked
  • Apply; OK

Leave a Reply

Your email address will not be published. Required fields are marked *