
HAVING ISSUES AND NEED HELP READ THIS FIRST BEFORE POSTING - viewtopic.php?p=908118
PUBLIC BANDWIDTH TEST SERVERS - viewtopic.php?t=104266
A. Configuring Off Bridge
B. Firewall
C. VLAN Filtering
D. AP/Switch RoS Setup
E. Destination NAT (Port Forwarding, hairpin nat & pihole/adguard)
F. Wireguard
G. Backup/Export Config
H. NetInstall & Protected Router Boot Mode (PRBM)
I1. IP Route Multi-WAN & Recursive
I2. NETWATCH Non-Recursive Option.
J. Directing Users out A Specific WAN with Routing Rules - (no mangling required)
J2. Ensuring Router Responds to requests from Same WAN ( no mangling required )
K1. Introduction to Mangling
K2. Directing Firewall Address List out A Specific WAN (with mangling)
L. Multi-WAN Input To Servers (with mangling)
M1. First Access to MT including WINBOX
M2. Beginner Basic Random Topics ( viewtopic.php?t=191442 )``
M3. PPPOE ISP with VLAN
N. Zerotier
O. Load Balancing PCC/Bandwidth
P. Switch Chip Vlans
Q. Mangling and Allowing Fastrack
R. Discovery/Cast Wireguard - EOIP VXLAN
S. OSPF Video Tutorials V7 --> https://www.youtube.com/playlist?list=P ... 3oaBTlWK3_
T. VRRP (HA) ( viewtopic.php?t=196051 )
Z. Super Useful Scripts
?. Capsman NOT INCLUDED! - not recommended for new users (besides being of a patriarchal nomenclature)
JUST STARTING TO CONFIG YOUR MIKROTIK DEVICE OR SIMPLY BROWSING - SEE BELOW
The first thing a new user should do is go straight to Para M. ( Para = Paragraph ) and watch the linked videos. If you have a grasp on the basics of winbox then the following order of help topics is designed to get you up and running safely and efficiently (A & B), and upon success one can venture into more interesting configurations that include vlans and using MT devices for other than routing (C & D) and finally, when ready, to start to tackle slightly more advanced topics/requirements (E & F) such as remotely and securely connecting to your device.
WARNING: Do not use QUICKSET to configure your router.
One may often use quickset to set the mode of the router (such as WISP mode for capac), or use the quickie VPN setup, but NEVER go back!!!
A. CONFIGURING (off) BRIDGE - viewtopic.php?t=181718 (all MT devices)
B. FIREWALL - viewtopic.php?t=180838
C. VLAN FILTERING read this --->[/b] ^^^- viewtopic.php?t=143620 ( pcunite's bible )
For nerds who wish to understand the bridge/vlan filtering construct, this is an excellent reference from The Chosen One: viewtopic.php?f=2&t=173692
To understand Bridge in a nutshell: Courtesy of Sindy, the Jakob Ingebrigtsen of MT Support.
You use a bridge interface whenever you want to connect multiple devices to the same IP subnet. Whether you use VLANs or not is a separate thing. You can use a dedicated bridge for each (V)LAN, you can use multiple bridges with multiple VLANs on each, or a single bridge for all your VLANs - it's up to your actual needs. But the bridge still forwards frames between its ports up to their MAC addresses only, and if the Mikrotik device on which this bridge exists wants to talk IP to the external devices connected to the bridge, you have to attach an IP address to the appropriate interface of the router - to the bridge-facing interface of the router directly or to the /interface vlan attached to it, depending on the rest of the configuration.
So again in different words - the interface of the router that is "connected" to the matching port of the virtual switch must have an IP address if you want that the router had access to devices in the same (V)LAN which is configured as an access one on that port of the virtual switch. If vlan-filtering is off, what came in tagged stays tagged on egress and what came in tagless stays tagged on egress; if vlan-filtering is on, you can tag frames on ingress and untag them on ingress. But that has nothing to do with attaching or not attaching IP addresses to interfaces.
When an IP stack sends a packet via an L2-capable interface, that packet gets encapsulated into a tagless ethernet frame (leaving wireless aside to simplify things). If the interface is the tagless end of the /interface vlan pipe, the frame gets an 802.1Q VLAN header as it passes through the pipe, so at the tagged end of the pipe, it is now a VLAN frame.
In the opposite direction, the pipes are "picky" - they only forward VLAN frames whose VID matches the one the pipe is configured to use, and untag them as they deliver them to their tagless end. They ignore frames with other VIDs.
You can attach the /interface vlan to an L2-capable interface directly, and you can also attach an IP address to it, but only if that L2-capable interface is not a member port of a bridge or a member link of a bond (exceptions exist but making use of them has side effects and causes incompatibility with less punky devices than Mikrotik is). At this step, we still think about the interface to which the IP address and/or /interface vlan pipes are attached as about the switch-facing interface of the router.
The next step is to see what happens to the frame as it enters the bridge via the router-facing port of the bridge. And here the difference between vlan-filtering=no and vlan-fltering=yes comes into play. With no, the bridge behaves like a "non-managed" (dumb) switch - it only cares about MAC addresses and nothing else. So if a frame came in tagless through one port, it will stay tagless on the bridge and as it egresses via another port(s). With yes, the bridge behaves like a "managed switch", so each of its ports can be an "access", "trunk", or "hybrid" one, depending on the settings. An access port only accepts tagless frames on ingress, tags them with the configured VID, and ignores tagged ones; a trunk port only accepts tagged frames (and may only accept those that bear the permitted VIDs), and a hybrid port is a combination of both behaviours. "Inside" the bridge, all frames are tagged, but if a tagless frame comes in through to a port with a certain pvid and egresses via another port with the same pvid, it will be tagless also at egress, as it gets tagged on ingress, passes through the bridge tagged, and then gets untagged on egress.
The router-facing port of the bridge behaves exactly the same like any other port of that bridge. So if you attach an IP address "to the bridge itself" (in fact, to the bridge-facing interface of the router), it will end up being reachable via the VLAN which is configured as pvid "on the bridge itself" (in fact, the router-facing port of the bridge). If the "bridge" port is in pure trunk mode, such an address will not be reachable at all. If you attach an IP address to an /interface vlan that is attached to the bridge-facing interface of the router, that address will be reachable via the corresponding VLAN if that VLAN is permitted also on the "router-facing port of the bridge" (which means that the router-facing port of the bridge is listed in the tagged list for that VLAN under /interface bridge vlan).
***** Did you Turn ON VLAN filtering after configuring /ip bridge port and /ip bridge vlan settings *****
^^^My advice is not to config/copy pcunite's formats verbatim from the first link above, its stilted and confusing. Instead simply using winbox, work through the Configuration Steps logically.
FIRST though, take one etherport and configure it so that it is accessible off the bridge to avoid getting locked out!!. SEE PARA A. above!!!
Add Bridge (or modify default Bridge as required)
Add VLANS with the parent interface being the Bridge
Create Subnet Structure for each VLAN (and likely modify the default subnet to be one of the VLANs)
Construct /interface bridge ports ( etherports and WLANs as applicable )
Construct /interface bridge vlans ( tagged and untagged **** Should match up with /interface bridge ports as a cross-check )
Make Changes to LAN Interface List ( remove bridge and add all vlans typically)
Add Management/Base Interface List & applicable members (Base Vlan and off bridge etherport for example)
Adjust Firewall Rules as necessary (Base List to Input Chain, LAN List to Input Chain for DNS, etc. ( required router services ))
Go to CLI and run export and see if any errors crop up.
Turn on bridge vlan filtering.
NOTE: **** To understand why its best to manually assign untagging, please read post #3 - viewtopic.php?p=956155#p956155
Note: MT help topics have vastly improved on this topic and can be found at:
https://help.mikrotik.com/docs/display/ ... NFiltering
https://help.mikrotik.com/docs/display/ ... VLAN+Table
Videos For setting up MT
https://www.youtube.com/watch?v=pdpFAxwocTo&t=467s
MT part1- https://www.youtube.com/watch?v=US2EU6cgHQU&t=299s
MT part2- https://www.youtube.com/watch?v=YMwOrc0LDP8
VLANS & HYBRID PORTS
Rule of Thumb: A Port (any port) can ONLY HAVE ONE "1" untagged vlan.
-An access port can only have one untagged vlan.
-A hybrid port can only have one untagged vlan (and as many tagged vlans as required - and obviously not tagged on the same vlan as untagged).
-A trunk port can only have one or more tagged vlans.
(example)
.......................
/bridge port ports
add bridge=bridge interface=ether5 pvid=10 {hybrid}
add bridge=bridge interface=ether6 pvid=10 {access}
add bridge=bridge interface=ether7 pvid=11 {access}
add bridge=bridge interface=ether8 {trunk}
/interface bridge vlan
add bridge=bridge tagged=bridge,ether5,ether8 untagged=ether7 vlan-ids=11
add bridge=bridge tagged=bridge untagged=ether5,ether6 vlan-ids=10
add bridge=bridge tagged=bridge,ether8 vlan-ids=14,15,16
D. AP SWITCH SETUP (using any RoS device as an AP/Switch) - viewtopic.php?t=182276
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
E. DESTINATION NAT & Port Forwarding - viewtopic.php?t=179343
F. WIREGUARD - viewtopic.php?t=182340
G. BACKUP/EXPORT CONFIG - https://help.mikrotik.com/docs/display/ROS/Backup / https://help.mikrotik.com/docs/pages/vi ... Id=2555971
(courtesy of mkx)
The most direct method is "BACKUP" - a binary file, created by the admin. This file is really only intended to restore a configuration on the very same device, preferably running the same version of ROS. If restored to another ROS version, there's a built-in configuration converter which mostly does a good job (but not always). If restored to another device of same type, MAC addresses are overwritten. Restoring it to a device of different model doesn't work (either creates random results or fails altogether).
Backup Function ---> Select Files in winbox.
Then next and most common method is called "EXPORT". This is an admin created text export of the current configuration. This text file shows commands needed to configure the device to its current state. This export lacks some items that make complete setup: users, passwords, certificates, SSH keys, etc. The benefit of using it is that it's text file, so it's pretty easy to apply it to a different device ... one has to adjust commands and that's it. It can be applied verbatim to a device, but a devices configuration needs to be completely blank beforehand.
Export Function ---> Select New Terminal in winbox. and use the apppropriate syntax.
Export Syntax For Admin
/export verbose file=anyname { shows every possible entry - rarely used }
/export show-sensitive file=anyname { useful for most admin work and NOT to be posted }
Export Syntax For Forum (public viewing)
/export hide-sensitive file=anyname { for version 6 }
/export file=anyname { for version 7 }
Note1:The EXPORT format is the preferred communication tool for forum members when discussing problems (screenshots are requested if needed).
Caution: One should not expose public IPs or public gateway IPs in any posted Export file or screenshot!
Note2: Export is best viewed using NOTEPAD++
----> Where to find DEFAULT CONFIG - /system default-configuration print
H. NETINSTALL & PROTECTED ROUTER BOOT MODE (PBRM)
NETINSTALL should be used if any security concerns arise OR if your firmware version seems to be acting strangely or the firmware version is really old!!
PBRM is mainly activated/used by those 'loaning' routers to customers and want to retain control over the firmware. viewtopic.php?t=181158
FOR MAC - https://tangentsoft.com/mikrotik/wiki?n ... 20on%20EL9
Another way of getting your unit(s) up to date is to netinstall devices. I would say it's preferred because it also installs recent default configuration while upgrades convert running configuration. A few versions between your running ROS and current one brought some big changes and it is possible for upgrade process to fail to convert old config to new one. In addition, new default config makes much more secure setup in certain aspects. In other words, if you are many firmware versions behind, netinstall is the least painless way to get to the latest config and is more secure.
Sage tips/advice on NetInstall if having difficulties......
a. Regarding Etherboot for all devices, the most error-free method is - to press the reset button, keep it pressed, power on the device, and wait until the device shows up in the NetInstall window, then release the button. This holds true for the Audience as well.
b. Try to have a direct cable connection between computer and device (laptop to device for example).
c. A trick which helps for some is to only use a dumb switch in between, nothing else connected.
d. Also on THE COMPUTER being used to run netinstall, there may be issues if there are multiple NETWORK interfaces. If experiencing difficulties on the PC, it is best to ensure all other NETWORK interfaces are turned off.
e. Enable NETBIOS, over TCP/IP ( active vice automatic or disabled )!
f. Apparently (fart, belch) some users have success using a LINUX computer vice Windows......... hard to believe but worth it if no luck otherwise !
User Comment: In my experience, Netinstall often fails to detect devices after the ethernet link to the MT device goes down and up again while netinstall is running.
Either place a dumb switch between the PC and the MT box to netinstall, so the PC ethernet link stays up during reboot while entering Etherboot.
Or first put the MT box in Etherboot mode, wait for the link to come up and start Netinstall after the link is up.
General Refs:
https://help.mikrotik.com/docs/display/ROS/Netinstall
https://help.mikrotik.com/docs/pages/vi ... Id=1409054
https://wiki.mikrotik.com/wiki/Manual:E ... set_button
RESET VIDEO FROM MikroTik - https://www.youtube.com/watch?v=6Unz92rABs8
I1. IP ROUTE - Multi-WAN & RECURSIVE { rp-filter=loose NOT strict }
There is much confusion on IP routes for the new beginner in part because we dont know how it got there in the first place. Mikrotik default settings in IP DHCP settings, typically for ether1, include two items of interest. Use ISP "PEER" DNS (check box selected) and use ISP Route ( Add Default Route is selected to "yes" ). Thus an IP Route is already provided (the default route) if the admin selects YES. One can uncheck this selection and enter manual routes which is usually the case once you get past one ISP provider. This section will focus on using manual routes which means ensuring the selection for Add Default Route is set to "no". The manual routes below will work regardless of firmware (6/7) chosen.
DUAL WAN - FAILOVER ( basic )
/ip route
add check-gateway=ping comment=Primary ISP distance=5 dst-address=0.0.0.0/0 gateway=Primary-gatewayIP
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=Secondary-gatewayIP
The syntax check-gateway=ping, tells the router to ping the gateway IP every 10 seconds or so. In this example, the router will still switch to ISP2, if ISP1 is not available ( and this could take awhile on a long lease), and the router will keep checking to see if WAN1 becomes available again, and if it does will switch router internet traffic back to ISP1 due to the fact that the shorter distance of ISP1 will also point the router to selecting ISP1 if both are available. THe key component here is distance. The route chosen all the time if both are available will be the one with the shortest distance.
Recursive Routing
In its simplest form/def'n - A recursive route is simply one that points to another route in your routing table instead of to a directly connected link.
Recursive routing occurs when a route either static route or dynamically learned has a next-hop that is not directly connected to the local router. This second lookup in the routing table is called recursion. A recursive route in general is one that points to a next-hop which isn't directly connected to the router. A directly connected link would be something that has your ISP gateway IP in the route. An internal route would be one on the router itself, (like all the subnet or vlan routes - dst-address=vlansubnet gwy=vlan-name)
WHY RECURSIVE? --> Many experienced admins don't trust that the router to ISP connection as the best way to ensure connectivity to the WWW. The reason is that often the ISPs internal network connection can be up (modem to next hop within the ISP network) but the ISPs connection to the internet is down. Thus the router will think the gateway is working when nothing on the internet can be reached. Admins solve this issue with something called "Recursive Routing".
To accomplish this, the admin, by use of the DNS addreses as the gateways, verifies the WAN connection works (is live). We ping those addresses to establish if the connection works and then transform the connection to the ACTIVE state. In the examples we are using a common DNS provider IP address such as 1.0.0.1, and 9.9.9.9.
TWO RULES OF THUMB (scope & target scope):
First Rule. The resolving route (DIRECT - connected route) with dst-address TO the "real WWW IP (dns site)" and with local ISP gateway IP, has Target-Scope=X and the recursive route (INDIRECT - external route) with gateway IP VIA the "real work WWW gateway IP (dns site)" has Target-Scope=X+1. In other words, the farther one gets from the router, the TS increases by one.
Second Rule. Between the same two routes being compared, the Direct , connected route, with local ISP gateway IP (resolving route) has to have a SCOPE that is equal to or less than the TARGET SCOPE of the recursive route. In other words, the scope of the route must be equal or less than the target scope of the next farthest route.
FARTHEST ROUTE: SCOPE= (doesnt matter) / TARGET SCOPE=Y+2 (recursive route)
CLOSER ROUTE: SCOPE= Y+2 or less / TARGET SCOPE=Y+1 (recursive route)
CLOSEST ROUTE: SCOPE=Y+1 or less / TARGET SCOPE=Y (gateway=ISP, resolving route)
INTERNAL ROUTE: ( within router, scope is not used, no recursive action at all )
Video LInk - https://www.youtube.com/watch?v=eTmpBAAW_pQ
DUAL WAN - RECURSIVE
/ip route
add check-gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 scope=10 target-scope=12
add distance=3 dst-address=1.0.0.1/32 gateway=PrimaryISP-gatewayIP scope=11 target-scope=11
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30
Note1: As you can see TS as you get closer to the router decreases by 1.
Note2: As you can see the scope of the next route is equal to or less than the TS of the preceding route.
USING TWO RECURSIVE ROUTES - FLAT
Additionally many admins also like to use at least two different public IPs to confirm connectivity (removes the rare but not rare enough occasion that DNS providers are not available). Thus as per the below example, a secondary DNS is checked to verify indeed that ISP1 is not available, when the first DNS checked is not working. If both DNS recursive routes show as not available, the router will select the Secondary WAN for all traffic. In the meanwhile the router will continue checking the availability of both DNS recursive routes for connectivity and will switch back to ISP1 if at least one of them is available.
/ip route
add check-gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 scope=10 target-scope=12
add distance=3 dst-address=1.0.0.1/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=11
+++++++++++++++++++
add check-gateway=ping distance=4 dst-address=0.0.0.0/0 gateway=9.9.9.9 scope=10 target-scope=12
add distance=4 dst-address=9.9.9.9/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=11
+++++++++++++++++++
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30
Note: As you may see, its easiest just to set all the scopes the same and in this case to 10, which ensures the Second Rule from above is followed.
USING TWO RECURSIVES - NESTED
Finally, admins can accomplish the same effect as the "flat" approach above by layering or nesting the recursive routes with each other with the same outcome. This is a more complex setup but is deemed to be more efficient overall especially if using multiple routing tables (academic and not required for new users). It is included for those interested. The tricky part is that we will use an address that really doesnt exist to force the router to look for a routing, in this case randomly choose 10.10.10.10/32. Thus we create a top rule with no apparent path and then recursively look for a path through both DNS addresses which then are resolved by the direct route through the ISP gateway. So although it appears we are using three Other addresses in nested recursive routing we are still only using 2 KNOWN DNS addresses and one 'BOGUS" address. The bogus address is used to force the router to be recursive for both the KNOWN Dns addresses. In other words, the flat approach is Recursive to Resolving (two steps), nested is Recursive to Recursive to Resolving (three steps).
/ip route
dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14
++++++++++++++++
add check-gateway=ping dst-address=10.10.10.10/32 gateway=9.9.9.9 scope=10 target-scope=13
add dst-address=9.9.9.9/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=12
+++++++++++++++
add check-gateway=ping dst-address=10.10.10.10/32 gateway=1.0.0.1 scope=10 target-scope=13
add dst-address=1.0.0.1/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=12
+++++++++++++++
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30
Note: All Primary routes have same distance, only the last Secondary route has a higher distance.
Example of two WANS both using recursive nested routing not just the primary and relying on 4 different external sites for checking.
distance=1 dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14
distance=2 dst-address=0.0.0.0/0 gateway=11.11.11.11 scope=10 target-scope=14
add check-gateway=ping dst-address=10.10.10.10/32 gateway=9.9.9.9 scope=10 target-scope=13
add check-gateway=ping dst-address=10.10.10.10/32 gateway=1.0.0.1scope=10 target-scope=13
add check-gateway=ping dst-address=11.11.11.11/32 gateway=8.8.8.8 scope=10 target-scope=13
add check-gateway=ping dst-address=11.11.11.11/32 gateway=208.67.222.222 scope=10 target-scope=13
add dst-address=9.9.9.9/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=12
add dst-address=1.0.0.1/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=12
add dst-address=8.8.8.8/32 gateway=SecondaryISP-gatewayIP scope=10 target-scope=12
add dst-address=208.67.222.222/32 gateway=SecondaryISP-gatewayIP scope=10 target-scope=12
DTRIPLE WAN - RECURSIVE Courtesy of AzDsL - This is a very challenging scenario. In this case, we have three WANS, where WAN1=dist1 WAN2=dist2 and WAN3=dist3. We have a number of subnets and the various subnets are connected to specific WANs. Subnets A&B (standard users) go to WAN1, Subnets C&D (VIP users) go to WAN2 and Subnet E&F (Other users) go to WAN3. One can only get so far before running into the wall of a common issue --> whenever a specific WAN is down and gets back, its assigned traffic won't be automatically routed back to is original gateway.
So how do we ensure that the specific conditions are met:
if WAN1 fails all gwy1 traffic goes to WAN2 and if WAN2 fails this traffic goes to WAN3
If WAN 2 fails all gwy2 traffic goes to WAN1 and if WAN1 fails this traffic goes to WAN3
if WAN3 fails all gwy3 traffic goes to WAN1 and if WAN1 fails this traffic goes to WAN2
As per other examples we need 3 tables.
/ip tables
add name=ISP1-route fib
add name=ISP2-route fib
add name=ISP3-route fib
and we need Routing Rules.
/ip routing rules
add src-address=10.100.100.0/24 action=lookup table=ISP1_route comment=STANDARD
add src-address=10.100.200.0/24 action=lookup table=ISP1_route comment=STANDARD
add src-address=10.200.123.0/24 action=lookup table=ISP2_route comment=VIP
add src-address=172.20.234.0/24 action=lookup table=ISP2_route comment=VIP
add src-address=192.168.111.0/24 action=lookup table=ISP3_route comment=OTHERS
add src-address=192.168.222.0/24 action=lookup table=ISP3_route comment=OTHERS
The final piece of the Recursive puzzle is modifying and adding failover routes for each of the routing rules with priority distance.
Where we start with the example of Dual WAN recursive above except we have a third virtual recursive IP:
STARTING POINT:
distance=1 dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14 { main table }
distance=2 dst-address=0.0.0.0/0 gateway=11.11.11.11 scope=10 target-scope=14 { main table }
distance=3 dst-address=0.0.0.0/0 gateway=12.12.12.12 scope=10 target-scope=14 { main table }
ADD:
distance=1 dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14 routing-table=ISP1-route
distance=2 dst-address=0.0.0.0/0 gateway=11.11.11.11 scope=10 target-scope=14 routing-table=ISP1-route
distance=3 dst-address=0.0.0.0/0 gateway=12.12.12.12 scope=10 target-scope=14 routing-table=ISP1-route
distance=1 dst-address=0.0.0.0/0 gateway=11.11.11.11 scope=10 target-scope=14 routing-table=ISP2-route
distance=2 dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14 routing-table=ISP2-route
distance=3 dst-address=0.0.0.0/0 gateway=12.12.12.12 scope=10 target-scope=14 routing-table=ISP2-route
distance=1 dst-address=0.0.0.0/0 gateway=12.12.12.12 scope=10 target-scope=14 routing-table=ISP3-route
distance=2 dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14 routing-table=ISP3-route
distance=3 dst-address=0.0.0.0/0 gateway=11.11.11.11 scope=10 target-scope=14 routing-table=ISP3-route
Then the rest of the routes are required, six with target scope of 13, and the last six with target scope of 12.
I1. NETWATCH - A Non-Recursive Option
J1. DIRECTING Users out Specific WAN Using Routing Rules { no mangling }
In multi-WAN setups, it is often that the admin needs to direct a whole subnet or one or more users out a specific WAN. This is typically applied when the users are supposed to go out a Primary WAN but a few users need to go out the Secondary WAN. The same approach by the way is used in Wireguard configs, when one has to force some users into the wireguard tunnel for internet (at a remote site) because the bulk of users locally go out the local WAN for internet. If you need a group of IPs and its too numerous for this method, check out the next paragraph which addresses ensuring an address list goes out a specific WAN.
Note: In Ver6 firmware Routing Rules take precedence over Mangling. In Ver7 firmware the reverse is true.
GENERAL EXAMPLE
Version 6 approach
Solution: Consists of two steps: ONE - create an additional route for the secondary WAN (copy of the original one) and add a routing-mark!, and TWO - create an associated Routing Rule which will direct the User to that Routing Mark via its Table selection parameter.
[Step1]
dst-address=0.0.0.0/0 gwy=ISP1 distance=5 check-gateway=ping
dst-address=0.0.0.0/0 gwy=ISP2 distance=10
dst-address=0.0.0./0 gwy=ISP2 distance=10 routing-mark=useSecondary
[Step 2]
/ip routing rule
add src-address=SUBNET or IPaddress Action=Lookup-only-in-table table=useSecondary
Version 7 approach
Solution: Very similar to the Version 6 approach but we have to physically create the new table and adjust the additional route by changing from the default table=main, to table=new table constructed ( and no use of route-marking ).
[Additional Step]
/routing table add fib name=useSecondary
Note1: Action=Lookup-only-in-table means the router will NOT look for any other routing for said traffic in the main table, if the Secondary WAN is not available, and the traffic will be dropped.
Note2: If the admin wants the users to be able to access the Primary WAN, if the Secondary WAN is down, then use ACTION=Lookup.
MULTIPLE USERS
If you have more than one user, that needs to be 'redirected', then simply create MULTIPLE Routing Rules! .
/routing rule add src-address=IP1 action=lookup table=useSecondary { for first IP }
/routing rule add src-address=IP2 action=lookup table=useSecondary { for second IP }
...
...
/routing rule add src-address=IPXX action=lookup table=useSecondary { for last IP }
Note3 (see below) : Routing Rule order counts much like firewall rules etc. This may come into play when you have more complex requirements.
COMPLEX CASE: [ Three Subnets ]
THREE SUBNETS. Primary WAN is for subnet A and subnet B, but users on subnet C should go out Secondary WAN. In addition, one user on subnetC (the exception) should actually follow the same routing as subnets A&B. In terms of failover, users from subnet A and B should be able to use ISP2, if ISP1 is not available. However, users from subnet C should not have access to ISP1 if ISP2 is not available.
In terms of planning purposes, it should be clear that we are going to have to redirect Subnet C users to WAN2. In addition we are going to have redirect Exception User on Subnet C to mimick routing that users on Subnets A,B follow. Therefore we will have to create additional routes for both WANS, to be able to force users as needed. (subnet C to wan2, exception user on subnet C to wan1)
dst-address=0.0.0.0/0 gwy=ISP1 table=main distance=5 check-gateway=ping
dst-address=0.0.0.0/0 gwy=ISP2 table=main distance=10
dst-address=0.0.0.0/0 gwy=ISP1 table=main distance=5 check-gateway=ping table=usePrimary
dst-address=0.0.0./0 gwy=ISP2 distance=10 table=useSecondary
/routing table add name=usePrimary fib
/routing table add name=useSecondary fib
/routing rule add src-address=Exception IP action=lookup table=usePrimary { for exception user on subnet C }
/routing rule add src-address=subnetC action=lookup-only-in-table table=useSecondary { for subnet C }
Order is key: If we had the routing rules order reversed, the exception user would have been captured by that Routing Rule, since located in subnet C and forced to WAN2, thus we had to match that user to the correct routing rule, FIRST, to ensure traffic went to WAN1
SERVER EXAMPLE: [ Local User Access to server NOT EXTERNALLY FACING ]
It is thusly possible to direct a server out a specific WAN. Lets say we have a VOIP server 10.10.10.2 that has been directed out WAN2.
/routing table add name=useWAN2
/routing rule add src-address=10.10.10.2/32 action=lookup-only-in-table table=useWAN2
/ip route
dst-address=0.0.0.0/0 gateway=WAN2ISP table=useWAN2
/routing rule add dst-address=10.10.10.2/32 action=lookup-only-in-table table=main
/routing rule add src-address=10.10.10.2/32 action=lookup-only-in-table table=useWAN2
SUBNET TO SUBNET: [ Local Users need to go out WAN2 but ALSO reach other subnets on the LAN ]
This same problem arises, when the admin also needs to allow subnets to talk to one another when they are being "forced" out a specific WAN. As demonstrated above, use of additional ROUTE RULES does the job with the use of destination addresses!
In this example, subnet 10.20.0.0 needs to go out WAN2 vice WAN1 (which the other two subnets use as WAN1 is primary by distance). However we still want the subnet to be able to have a path to the other two subnets. The key is to provide routing rules for such traffic PRIOR to the useWAN2 route rule (and destination address as applicable).
...........
/routing rule
add dst-address=192.168.0.0/16 action=lookup-only-in-table table=main
add dst-address=10.0.0.0/8 action=lookup-only-in-table table=main
add src-address=10.20.0.0/22 action=lookup table=useWAN2
J2. ENSURING Same WAN for Return Traffic { no mangling }
When one wants to ensure incoming requests TO THE ROUTER (services such as wireguard) in a multi-wan setup, are returned via the correct same WAN, then
one can use Routing Rules to accomplish this task. Unlike mangling, Routing Rules are considered prior to Routing. Manging(in output chain) is considered after Routing
Hence lets look at two WANs.
/add fib table=preferWAN1
/add fib table=preferWAN2
/routing rule add src-address=WANIP1 action=lookup-only-in-table table=preferWAN1 { we ensure wan1 replies via ISP1 }
/routing rule add src-address=WANIP2 action=lookup-only-in-table table=preferWAN2 { we ensure wan2 replies via ISP2 }
/ip route
add dst-addres=0.0.0.0 gateway=ISP1 routing-table=preferWAN1
add dst-addres=0.0.0.0 gateway=ISP2 routing-table=preferWAN2
Note: If ISP provides a dynamic WANIP one will need scripts to update the src-address and most likely gateway IP as well.
Routing Recap: Order for Routing is
a. Routing Table
b. Best matching dst-address
c. route activity
When does distance come into effect?
Among all routes with identical routing table name and same dst-address, the active one is chosen among all those that can work ( interface up, check gateway says its available) distance determines which route is chosen.
(Note: Keep in mind that routing marks assigned in mangling take precedence over those used in Routing Rules.)
................................
K1. Introduction to Basic Mangling -
TWO WANS and TWO LANS - both LANs contain at least one server
In the previous example we were only concerned about local traffic being controlled out the WAN. Now we are going to add the requirement to ensure external traffic coming in a particular WAN leaves the same WAN. This will be accomplished by two sets of mangle rules in the pre-routing chain, basically marking packets entering each WAN and then associating those packets with a route mark that equates to the associated WANX routing-table we created previously for forcing LANX out the specific WANX. We will apply this two TWO LANS and TWO WANS.
Note: In Ver7 firmware Mangling takes precedence over Routing Rules. In Ver6, the reverse is true.
Requirements: LAN1 needs to go out WAN1 and LAN2 needs to go out WAN2. Additionally we have servers on both LANS that external users access and thus we need to ensure incoming user return traffic, after hitting the servers, goes back out the same WAN.
Notes
1. Both WANs are from the same ISP so there is no failover discussion.
2. We only need two create two tables as they will be used both by mangle rules for external traffic (routing-mark) and routing rules for internally originated traffic. (table=) as well as for the IP ROUTEs directing traffic out each gateway and corresponding table.
Tables:
/routing-table add fib name=viaISP1
/routing-table add fib name=viaISP2
Mangles
/ip firewall mangle
add action=mark-connection chain=prerouting connection-mark=no-mark \
in-interface=ether1 new-connection-mark=WAN1 passthrough=yes
add action=mark-connection chain=prerouting connection-mark=no-mark \
in-interface=ether2 new-connection-mark=WAN2 passthrough=yes
=============================================================================
add action=mark-routing chain=prerouting connection-mark=WAN1 \
new-routing-mark=viaISP1 passthrough=no
add action=mark-routing chain=prerouting connection-mark=WAN2 \
new-routing-mark=viaISP2 passthrough=no
Routing Rules
/routing rules
add src-address=LAN1-subnet action=lookup-in-table-only table=viaISP1
add src-address=LAN2-subnet action=lookup-in-table-only table=viaISP2
/ip route
add distance=1 gwy=WAN1 table=main {standard route}
add distance=1 gwy=WAN2 table=main {standard route}
add distance=1 gwy=WAN1 table=viaISP1 { route for both external return traffic and local originated traffic on LAN1 to go out WAN1}
add distance=1 gwy=WAN2 table=viaISP2 route for both external return traffic and local originated traffic on LAN2 to go out WAN2}
K2. MULTI-WAN & Firewall Address List & Mangling (PCC) }
In this type of scenario you EITHER have a group of internal/local IP addresses (could be something less than a subnet or bunches of IPs from different subnets) where route rules are just to onerous OR you have a bunch of specific destination addresses that when selected from ANY user, should go out a specific WAN. In these cases its typical to disable fasttrack as mangling and fasttrack are not compatible.
SOURCE ADDRESS BASED EXAMPLE
Assuming two separate PPPOE connections for a dual WAN scenario and a firewall address list called special-group, where this group needs to go out pppoe-2
/ip route
add gateway=pppoe-out1
add gateway=pppoe-out2
add gateway=pppoe-out2 routing-mark=specific-users (<--- V 6+++ V7 --->) add gateway=pppoe-out2 table=specific-users
/ip firewall mangle
add chain=prerouting src-address-list=special-group action=mark-routing new-routing-mark=specific-users { (same for v6 and v7)}
..............
If you wish to keep fasttrack for the rest of the traffic, modify two copies of the regular established,related rule and put them in front of the fasttrack rule - one rule for originating traffic and one rule for returning traffic. The modification is the addition of the firewall address list!
add action=accept chain=forward connection-state=established,related src-address-list=special-group
add action=accept chain=forward connection-state=established,related dst-address-list=special-group
DESTINATION ADDRESS BASED EXAMPLE
Assuming two separate PPPOE connections for a dual WAN scenario and a firewall address list of destination addresses called external-group, where any traffic headed towards these destinations needs to go out pppoe-2.
/ip route
add gateway=pppoe-out1
add gateway=pppoe-out2
add gateway=pppoe-out2 routing-mark=dest-exception
/ip firewall mangle
add chain=prerouting dst-address-list=external-group action=mark-routing new-routing-mark=dest-exception
add action=accept chain=forward connection-state=established,related dst-address-list=external-users
add action=accept chain=forward connection-state=established,related src address-list=external-users
L. MULTI-WAN Input To Servers & Mangling { rp-filter=loose NOT strict / fastrack=disabled }
For discussion purposes we are describing a scenario where the Admin has one or more servers behind the router and they should be accessible from both WAN connections, regardless of which is Primary or which is Secondary. How the users reach the servers is up to the admin. Basically the idea is to capture the incoming traffic from external users and then ensure the traffic goes out the same WAN it came in on! (Thanks to Sob) the following script forms the basis for this V7 approach:
/routing table
add name=ISPx_route fib
/ip route
add dst-address=0.0.0.0/0 gateway=<ISPx gateway> table=main { comment: For local originated traffic }
add dst-address=0.0.0.0/0 gateway=<ISPx gateway> table=ISPx_route { comment: For external originated traffic to servers } { V7 method }
/ip firewall mangle
add chain=prerouting in-interface=WANx connection-state=new action=mark-connection new-connection-mark=WANx_conn
add chain=prerouting in-interface-list=LAN connection-mark=WANx_conn action=mark-routing new-routing-mark=ISPx_route
The only difference between V7 and V6, is that in V6 there is no separate table and one adds the routing-mark in the ip route not the table!
/Iip route
add dst-address=0.0.0.0/0 gateway=<ISPx gateway> routing-mark=ISPx-route { comment: For external originated traffic to servers }
Note: Both approaches (using connection-state=new OR connection-mark=no-mark) are equally valid!
Example 1: DUAL WAN FAILOVER
...................................................
/ip routing table
add name=ISP1_route fib
add name=ISP2_route fib
/ip route
add check-gateway=ping comment=Primary ISP distance=5 dst-address=0.0.0.0/0 gateway=Primary-gatewayIP
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=Secondary-gatewayIP
add comment=Primary ISP distance=5 dst-address=0.0.0.0/0 gateway=Primary-gatewayIP table=ISP1_route
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=Secondary-gatewayIP table=ISP2_route
/ip firewall mangle
add chain=prerouting in-interface=WAN1 connection-state=new action=mark-connection new-connection-mark=WAN1_conn
add chain=prerouting in-interface-list=LAN connection-mark=WAN1_conn action=mark-routing new-routing-mark=ISP1_route
add chain=prerouting in-interface=WAN2 connection-state=new action=mark-connection new-connection-mark=WAN2_conn
add chain=prerouting in-interface-list=LAN connection-mark=WAN2_conn action=mark-routing new-routing-mark=ISP2_route
Note: The Table and Mangle creation are identical for all examples.
Example 2: DUAL WAN FAILOVER RECURSIVE
.................
/ip route
add check-gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 scope=10 target-scope=12 table=main
add check-gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 scope=10 target-scope=12 table=ISP1_route
add distance=3 dst-address=1.0.0.1/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=11 table=main
..............................................................................................
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30 table=main
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30 table=ISP2_route
Example 3: DUAL WAN FAILOVER TWO RECURSIVE (flat)
.....................
/ip route
add check=gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 scope=10 target-scope=12 table=main
add check-gateway=ping distance=3 dst-address=0.0.0.0/0 gateway=1.0.0.1 scope=10 target-scope=12 table=ISP1_route
add distance=3 dst-address=1.0.0.1/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=11 table=main
....................................................................................................................................................................
add check-gateway=ping distance=4 dst-address=0.0.0.0/0 gateway=9.9.9.9 scope=10 target-scope=12 table=main
add check-gateway=ping distance=4 dst-address=0.0.0.0/0 gateway=9.9.9.9 scope=10 target-scope=12 table=ISP1_route
add distance=4 dst-address=9.9.9.9/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=11 table=main
..............................................................................................
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30 table=main
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30 table=ISP2_route
Example 4: DUAL WAN FAILOVER TWO RECURSIVES (nested)
................................
dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14 table=main
dst-address=0.0.0.0/0 gateway=10.10.10.10 scope=10 target-scope=14 table=ISP1_route
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
add check-gateway=ping dst-address=10.10.10.10/32 gateway=9.9.9.9 scope=10 target-scope=13
add dst-address=9.9.9.9/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=12
add check-gateway=ping dst-address=10.10.10.10/32 gateway=1.0.0.1 scope=10 target-scope=13
add dst-address=1.0.0.1/32 gateway=PrimaryISP-gatewayIP scope=10 target-scope=12
..................................................................................................................................................
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30 table=main
add comment=SecondaryISP distance=10 dst-address=0.0.0.0/0 gateway=SecondaryISP-gatewayIP scope=10 target-scope=30 table=ISP2_route
Example 5: TRIPLE WAN FAILOVER ONE RECURSIVES & PCC MANGLING (flat)
....................................................
a. if WAN2 fails, send WAN2 traffic to Wan3, if Wan3 then fails, send WAN2 & WAN3 traffic to Wan4
b. if WAN3 fails, send WAN3 traffic to Wan2, if Wan2 then fails, send WAN3 &WAN2 traffic to Wan4
c. If WAN4 fails, send WAN4 traffic to Wan2, if Wan2, then fails, send WAN4 & WAN2 traffic to Wan3
This should get you close in terms of IP routes.
Starting Point Farthest Hop.
...................................
/ip route
add check-gateway=ping dst-address=0.0.0.0/0 gateway=1.1.1.1 scope=10 target-scope=14 { main table }
add check-gateway=ping dst-address=0.0.0.0/0 gateway=39.39.39.39 scope=10 target-scope=14 {main table }
add check-gateway=ping dst-address=0.0.0.0/0 gateway=8.8.4.4 scope=10 target-scope=14 {main table }
Add Cases for Failure..... ( W2--> 3 then 4 / W3--> 2 then 4 / W4--> 2 then 3 )
distance=1 dst-address=0.0.0.0/0 gateway=1.1.1.1 scope=10 target-scope=14 routing-table=prefer-ISP2
distance=2 dst-address=0.0.0.0/0 gateway=39.39.39.39 scope=10 target-scope=14 routing-table=prefer-ISP2
distance=3 dst-address=0.0.0.0/0 gateway=8.8.4.4 scope=10 target-scope=14 routing-table=prefer-ISP2
distance=1 dst-address=0.0.0.0/0 gateway=39.39.39.39 scope=10 target-scope=14 routing-table=prefer-ISP3
distance=2 dst-address=0.0.0.0/0 gateway=1.1.1.1 scope=10 target-scope=14 routing-table=prefer-ISP3
distance=3 dst-address=0.0.0.0/0 gateway=8.8.4.4 scope=10 target-scope=14 routing-table=prefer-ISP3
distance=1 dst-address=0.0.0.0/0 gateway=8.8.4.4 scope=10 target-scope=14 routing-table=prefer-ISP4
distance=2 dst-address=0.0.0.0/0 gateway=1.1.1.1.1 scope=10 target-scope=14 routing-table=prefer-ISP4
distance=3 dst-address=0.0.0.0/0 gateway=39.39.39.39 scope=10 target-scope=14 routing-table=prefer-ISP4
ADD NEXT HOP (Direct LINK)
.......................................
/ip route
add dst-address=1.1.1.1/32 gateway=192.168.12.1 scope=10 target-scope=13
add dst-address=39.39.39.39/32 gateway=192.168.13.1 scope=10 target-scope=13
add dst-address=8.8.4.4/32 gateway=192.168.14.1 scope=10 target-scope=13
MANGLING - 3 WANS WITH PCC ( with failover and one PPP network internally )
A. Have to ensure any users coming in externally for mainly the internal server, on any WAN, go back out the same WAN.
This rule has two purposes, to mark incoming traffic headed toward a server etc, or to the router itself!
..........
add action=mark-connection chain=prerouting connection-mark=no-mark \
in-interface=WAN2 new-connection-mark=WAN2_conn passthrough=yes
add action=mark-connection chain=prerouting connection-mark="" in-interface=\
WAN3 new-connection-mark=WAN3_conn passthrough=yes
add action=mark-connection chain=prerouting connection-mark=no-mark \
in-interface=WAN4 new-connection-mark=WAN4_conn passthrough=yes
B. Next we have to ensure all users originating traffic heading for the WANs are both connection marked and PCCd. Since we have the standard LAN and anther ppp subnet to worry about (not really an interface) we need to use a firewall address list vice and interface list approach.
/ip firewall address list
add address=192.168.15.0/24 list=ALL-users
add address=192.168.20.0/24 list=ALL-users
And then the PCC rules and marking connections for the internal originating traffic.
.......................
add action=mark-connection chain=prerouting connection-mark=no-mark \
dst-address-type=!local src-address-list=ALL-users new-connection-mark=\
WAN2_conn passthrough=yes per-connection-classifier=\
both-addresses-and-ports:4/0
add action=mark-connection chain=prerouting connection-mark=no-mark \
dst-address-type=!local src-address-list=ALL-users new-connection-mark=\
WAN3_conn passthrough=yes per-connection-classifier=\
both-addresses-and-ports:4/1
add action=mark-connection chain=prerouting connection-mark=no-mark \
dst-address-type=!local src-address-list=ALL-users new-connection-mark=\
WAN3_conn passthrough=yes per-connection-classifier=\
both-addresses-and-ports:4/2
add action=mark-connection chain=prerouting connection-mark=no-mark \
dst-address-type=!local src-address-list=ALL-users new-connection-mark=\
WAN4_conn passthrough=yes per-connection-classifier=\
both-addresses-and-ports:4/3
....................
add action=mark-routing chain=prerouting connection-mark=WAN2_conn \
src-address-list=ALL-users new-routing-mark=to_WAN2 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN3_conn \
src-address-list=ALL-users new-routing-mark=to_WAN3 passthrough=yes
add action=mark-routing chain=prerouting connection-mark=WAN4_conn \
src-address-list=ALL-users new-routing-mark=to_WAN4 passthrough=yes
D. Lastly we want to ensure any traffic that was headed for the router itself through the WANs,
gets sent back out the same interface.
Note: Return traffic from the Router itself does not go through preouting and thus we must use output chain.
.........................
add action=mark-routing chain=output connection-mark=WAN3_conn \
new-routing-mark=to_WAN3 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN4_conn \
new-routing-mark=to_WAN4 passthrough=yes
add action=mark-routing chain=output connection-mark=WAN2_conn \
new-routing-mark=to_WAN2 passthrough=yes
M1. First Time Access & WINBOX (must watch videos for the new user)
First Access/Config - https://www.youtube.com/watch?v=Q9qwgKrw-0g
Access/Quickset - https://www.youtube.com/watch?v=JR8OJPNhwjM
{Please note that quickset should only be used to set the initial mode of the router ( capac --->wisp mode) and NEVER touched again!}
More on Winbox - https://www.youtube.com/watch?v=MKVJYxhmSkQ
Basic Firewall - https://www.youtube.com/watch?v=6boYA7xdjZY&t=1376s
Basic Routing - https://www.youtube.com/watch?v=FBknCFkH0J8&t=21s
Static Routes - https://www.youtube.com/watch?v=ZYeMuYBAVrQ&t=214s
Intro to CLI - https://www.youtube.com/watch?v=EYCjuvTd3dY
CLI Tips - https://www.youtube.com/watch?v=fSt1UrNcx08
M2. Beginner Topics Random - viewtopic.php?t=191442
M3. When your ISP assigns you a PPPOE with VLAN20 and the WAN port used is your SFP port.
.........
interface vlan add vlan-id=20 interface=sfp1 name=vlan20
interface pppoe-client add interface=vlan20 name=PPPoE_Out user=xxxxx password=yyyyyy use-peer-dns=yes add-default-route=yes
N. ZEROTIER (courtesy of Amm0)
viewtopic.php?t=183424
Excellent Video from Mikrotik - https://www.youtube.com/watch?v=60uIlyF8Z5s
https://help.mikrotik.com/docs/display/ROS/ZeroTier
O. LOAD BALANCE
https://mum.mikrotik.com/presentations/US12/steve.pdf via PCC
https://mum.mikrotik.com/presentations/US12/tomas.pdf via Bandwidth
Note: For Dynamic IPs, and Fib Routes, use interface name (ether2, pppoe-out1 etc.) as gateway IP is unknown.
P. SWITCH CHIP VLANS
Switch Chip Features - https://help.mikrotik.com/docs/display/ ... p+Features
CRS1 / CRS2 -Switches - https://help.mikrotik.com/docs/pages/vi ... =103841835
CRS3 / CRS5 / CCR2 Switches - https://help.mikrotik.com/docs/display/ ... p+features
L3 Hardware Offloading - https://help.mikrotik.com/docs/display/ ... Offloading
Other Devices (older) Basic - https://help.mikrotik.com/docs/display/ ... switchchip
other refs:
https://www.youtube.com/watch?v=Rj9aPoyZOPo - Vlans using the Switch Chip
https://www.youtube.com/watch?v=rvQ6o4RfnoU - Configure Vlan on Switch Chip
https://www.youtube.com/watch?v=YLtGQAQ8iS0 - CRS3XX Step by Step
CRS1xx VLAN Example
###############################################################################
# Recommended reading
# https://wiki.mikrotik.com/wiki/Manual:Basic_VLAN_switching
#
# Notes: Start with a reset (/system reset-configuration)
#
# Based on: https://forum.mikrotik.com/viewtopic.php?t=143620
###############################################################################
#######################################
# Naming
#######################################
# name the device being configured
/system identity set name="CRS1xx_Switch"
#######################################
# VLAN Overview
#######################################
# 10 = BLUE
# 20 = GREEN
# 30 = RED
# 99 = BASE (MGMT) VLAN
#######################################
# Bridge
#######################################
# create one bridge
/interface bridge add name=BR1 protocol-mode=none
# add "all" ports to this one bridge
/interface bridge port
add bridge=BR1 interface=ether1
add bridge=BR1 interface=ether2
add bridge=BR1 interface=ether3
add bridge=BR1 interface=ether4
# and so on until you get to 24 ...
#######################################
# -- Access Ports --
#######################################
# ingress behavior, egress dynamically handled
/interface ethernet switch ingress-vlan-translation
add customer-vid=0 new-customer-vid=10 ports=ether2
add customer-vid=0 new-customer-vid=20 ports=ether3
add customer-vid=0 new-customer-vid=30 ports=ether4
#######################################
# -- Trunk Ports --
#######################################
# ingress behavior
# L2 switching only, Bridge (aka switch1-cpu) not needed as tagged member (except for BASE_VLAN)
/interface ethernet switch vlan
add ports=ether1,ether2 vlan-id=10
add ports=ether1,ether3 vlan-id=20
add ports=ether1,ether4 vlan-id=30
add ports=switch1-cpu,ether1 vlan-id=99
# egress behavior
# L2 switching only, Bridge (aka switch1-cpu) not needed as tagged member (except for BASE_VLAN)
/interface ethernet switch egress-vlan-tag
add tagged-ports=ether1 vlan-id=10
add tagged-ports=ether1 vlan-id=20
add tagged-ports=ether1 vlan-id=30
add tagged-ports=switch1-cpu,ether1 vlan-id=99
#######################################
# VLAN Security
#######################################
# drop traffic that does not follow the above port layout
/interface ethernet switch set forward-unknown-vlan=no
#######################################
# IP Addressing & Routing
#######################################
# LAN facing Switch's IP address on a BASE_VLAN
/interface vlan add interface=BR1 name=BASE_VLAN vlan-id=99
/ip address add address=192.168.0.2/24 interface=BASE_VLAN network=192.168.0.0
# The Router's IP this switch will use
/ip route add distance=1 gateway=192.168.0.1
#######################################
# MAC Server settings
#######################################
# Ensure only visibility and availability from BASE_VLAN, the MGMT network
/interface list add name=BASE
/interface list member add interface=BASE_VLAN list=BASE
/ip neighbor discovery-settings set discover-interface-list=BASE
/tool mac-server mac-winbox set allowed-interface-list=BASE
/tool mac-server set allowed-interface-list=BASE
Q. MANGLING & ALLOWING FASTTRACK
viewtopic.php?t=134048#p659676
R. DISCOVERY/CAST WIREGUARD EOIP VXLAN
viewtopic.php?t=194646
Z. SUPER USEFUL SCRIPTS
Script Syntax Info:
(i) if you want to use an output of one command as a value for another command (or expression), you must put that "one command" into [], such as
:put [:resolve www.google,com]
(ii) if you want to put more commands as a parameter of another command, you have t use {}, such as
:if (x=y) do={command1 ; command2 ; command3}
(iii) :do { put there command you want to run; } on-error={ put command to be run on error}
Scripts
a. Capture LOGGED IPs into Firewall Address list (Vers 1.5 Jotne/Rext) - viewtopic.php?p=905420#p906705
b. SCHEDULER USE (not script) Turn off / on Interface at specific times (CZFAN) - viewtopic.php?t=131494#p645744
c. REMOVE OLD Connections when WAN interface changes (Rextended) - viewtopic.php?f=9&t=154606&p=853803&hil ... ve#p853803
d. Use a DYNDNS provider such as DYNU (Rextended) - viewtopic.php?p=961067#p961068
e. SEND AN EMAIL for when a New User/Device connects - viewtopic.php?t=191991#p974371
f. Force IP CLOUD update through WANX - viewtopic.php?p=962282&hilit=force+cloud+to+use#p963399
g. WIREGUARD CURRENT USERS
/interface/wireguard/peers/print detail where last-handshake < [:totime "3m"]
h. Security: REMOVE Logged in (BUT INACTIVE) USERS - viewtopic.php?t=198410#p1018445