Two bridges sharing one port

... yes, I know it can't be done. But that's what I need the router to do.

I'm looking for the easiest and most robust way to turn my mikrotik router (L009UiGS-2HaxD) with 8 ports into a hybrid switch / router, where eth1 is connected to an upstream LAN (traditionally the WAN), ports 2,3,4 are as per usual (having their own separate LAN with their own DHCP and firewall, etc and going out through eth1), AND ports 5,6,7,8 are like they're on a switch which connects directly to the LAN that eth1 is connected to. So devices on ports 5,6,7,8 would think they're on the same LAN as eth1.

I've looked at using VLANs but I'm not sure I have the design correct. (I should mention that I'm having to do this remotely from 1,000km away with no local help so if things go bad, even though I'm relying a lot on SafeMode, then it will be a very sad day for me.)

Any other easy way to achieve this? Perhaps by just adjusting the default firewall a little?

Looking forward to the replies.

Cheers,

  • BPC

Which port is shared by two bridges in your setup?

What you describe is two bridges, one with ports 1, 5-8 and another with 2-4. The second has a DHCP server, etc. and you route between them. (As if the first bridge was a WAN, and the second the LAN in typical setups.)

The same can be done a bit more optimally with vlans, where all ports are in a single vlan-aware bridge, 1, 5-8 being access ports to e.g. vlan 100, and 2-4 to a.g. vlan 200. Then you attach two vlan interfaces to the bridge and one of them is considered the WAN, the other LAN.

Now doing this from 1000km away whilst speed-solving Rubik's cubes and whistling O Fortuna, now that's always a bit complicated :slight_smile:

To recap you have a single subnet coming in from an upstream device. Is it coming on a vlan tagged port on the upstream device or simply as a subnet connected on the etherport??

Either way this upstream source has two flows to perform, reach your router and is terminated as its IP DHCP client and also to move to ports 5,6,7,8.

Thus you will have to make the incoming port a trunk port if already coming to you as a tagged vlan or as an access port if coming as an untagged stream of traffic. I will assume the latter.

Personally, for now I would use port 8 to configure the router from a safe spot and from which to eventually turn on vlan-filtering on the bridge. Rename the port to be clear....

From the default config,
Remove ether8 from the bridge
give it an IP address 192.168.77.130 interface=OffBridge8 network=192.168.77.0
ensure its part of a trusted and LAN interface
plug in your laptop and change ipv4 settings to 192.168.77.2 and you should be able to access the router.

+++++++++++++++++++++++++++++++++++++++++++++++++++++++

/interface bridge
add admin-mac=auto-mac=no comment=defconf name=bridge \
    port-cost-mode=short vlan-filtering=no { modify to 'yes'  as last item on the config }
set [ find default-name=ether1 ] name=ether1WAN
set [ find default-name=ether8 ] name=OffBridge8
/interface vlan
add interface=bridge name=SourceVLAN vlan-id=10
add interface=bridge name=vlan20-home vlan-id=20  comment="for home wired and wifi"
add interface=bridge name=vlan30-guest vlan-id=30  comment="for guest wifi"
add interface=bridge name=vlan40-iot  vlan-id=40   comment="for iot wifi devices"
/interface list
add comment=defconf name=WAN
add name=LAN
add name=TRUSTED
/interface wifi channel
add band=2ghz-ax name=wifi1-home2ghz 
add band=5ghz-ax name=wifi2-home5GHZ
add band=5ghz-ax name=wifi3-guest5GHZ 
add band=2ghz-ax name=wifi4-iot2ghz 
/interface wifi security
/interface wifi configuration
/ip pool
add name=dhcp_HOME_pool ranges=192.168.20.2-192.168.2.254
add name=dhcp_GUEST_pool ranges=192.168.30.2-192.168.1.254
add name=dhcp_IOT_pool ranges=192.168.40.2-192.168.2.254
/ip dhcp-server
add address-pool=dhcp_HOME_pool interface=vlan20-home lease-time=8h \
name=HOME-server
add address-pool=dhcp_GUEST_pool interface=vlan30-guest lease-time=8h \
    name=GUEST-server
add address-pool=dhcp_IOT_pool interface=vlan40-iot lease-time=8h \
    name=IOT-server
/ip neighbor discovery-settings
set discover-interface-list=TRUSTED
/interface bridge port
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=ether1WAN pvid=10
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=ether2 pvid=20 comment="home pc"
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=ether3 pvid=20  comment="home printer"
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=ether4 pvid=20 comment="home unmanaged switch"
+++++++++++++++++++++++++++++
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=wifi1-home2ghz pvid=20 comment="home wifi 2ghz"
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=wifi2-home5GHZ pvid=20  comment="home wifi 5GHZ" 
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=wifi3-guest5GHZ pvid=30 comment="guest-wifi 5GHZ"
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=wifi4-iot2ghz  pvid=40 comment="iot-wifi 2ghz"
++++++++++++++++++++++++++++
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=ether5 pvid=10
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=ether6 pvid=10
add bridge=bridge ingress-filtering=yes frame-types=admit-only-untagged-and-priority \
interface=ether7 pvid=10
/ip dhcp client
add default-route=yes interface=SourceVLAN
/interface bridge vlan
add bridge=bridge tagged=bridge untagged=ether1WAN,ether5,ether6,ether7 vlan-id=10
add bridge=bridge tagged=brdige untagged=ether2,ether3,ether4,wifi1-home2ghz,wifi2-home5GHZ vlan-id=20
add bridge=bridge tagged=bridge untagged=wifi3-guest5GHZ vlan-id=30
add bridge=bridge tagged=bridge untagged=wifi4-iot-2ghz vlan-id=30
/interface list member
add comment=defconf interface=SourceVLAN list=WAN
add interface=vlan20-home list=LAN
add interface=vlan30-guest list=LAN
add interface=vlan40-iot list=LAN
add interface=OffBridge8 list=LAN
add interface=vlan20-home list=TRUSTED
add interface=OffBridge8  list=TRUSTED
/ip address
add address=192.168.20.1/24 interface=vlan20-home network=192.168.20.0
add address=192.168.30.1/24 interface=vlan30-guest network=192.168.30.0
add address=192.168.40.1/24 interface=vlan40-iot network=192.168.40.0
add address=192.168.77.1/30 interface=OffBridge8 network=192.168.77.0
/ip dns
set server=192.168.10.1
/ip firewall filter
add action=accept chain=inputconnection-state=established,related,untracked
add action=drop chain=input connection-state=invalid
add action=accept chain=input protocol=icmp
add action=accept chain=input dst-address=127.0.0.1
add action=accept chain=input comment="admin" in-interface-list=TRUSTED
add action=accept chain=input comment="users to services" in-interface-list=LAN \
dst-port=53 protocol=udp
add action=accept chain=input comment="users to services" in-interface-list=LAN \
dst-port=53 protocol=tcp
add action=drop chain=input comment="drop all else"
+++++++++++++++++++++++++++++++++++++++++++++++
add action=fasttrack-connection chain=forward connection-state=established,related
add action=accept chain=forward connection-state=established,related,untracked
add action=drop chain=forward connection-state=invalid
add action=accept chain=forward comment="internet traffic" out-interface-list=WAN
add action=accept chain=forward comment="admin to lans" in-interface-list=TRUSTED out-interface-list=LAN
add action=drop chain=forward comment="drop all else"
/ip firewall nat
add action=masquerade chain=srcnat comment="defconf: masquerade" \
    ipsec-policy=out,none out-interface-list=WAN
/tool mac-server
set allowed-interface-list=none
/tool mac-server mac-winbox
set allowed-interface-list=TRUSTED

This example includes 3 vlans behind your router and the one subnet coming in.
This example includes four wifi SSIDs, two for home, one for guest and one for iot.

I think that It will be difficult to take advantage of the Offbridge emergency access from 1000 km away.

If this Is the situation, I would strongly suggest making a GNS3 (or other network simulator) EXACT copy of the remote network and test not only the "final" configuration, but also - in each single step - the way this configuration is applied ( the Devil Is often in the details).

Yikes I missed that point.
If you have a MT router at home/office ( admin router) and can set it up as the server for handshake, I would create a wireguard interface on this remote router (as client device for handshake) and set it up so it phones your router so you have admin connectivity whenever required. I would be tempted to setup an SSTP withour creditials direct link between your MT admin router and the remote router and depending upon the router, probably setup a BTH tunnel separately so that you can reach it if both the above are not working.
Finally, try to setup a PC in the remote area that you can anydesk into, and thus access the router.
In that case does the Router have a public IP or can forward port from upstream ISP router or other.

Jaclaz, assuming there might be some IT person or trustworthy person at the remove location,
they could then be instructed to enter the router through the off bridgte port to make some changes over teams etc.......

Share exact actual FULL config (/export file=mycfg) for check if is doable easily.
CENSORE (not delete) real public ips, usernames and passwords, ssids, serial numbers.

I'm thinking of taking @anav's directions (reducing the private LANs to one) and giving it a go.
Ofcourse, I'm very concerned of locking myself out of the system.
If there were a sandbox I could try this that would be great. I'd even pay to access it. I think I remember reading somewhere that RouterOS can run in the cloud, so this should be possible.
FYI. I'm a software developer and not a network engineer (I took the easy path in my CS degree). So I'm working through this slowly.
Thanks for all the helpful replies so far. Very grateful.

Two questions,
Do you have/admin your home MT or office MT router??
How do you currently reach the remote device??

Remember would need to see both configs to setup up secure connectivity.........
Is the L1009 the remote device or the one at home/office?
In other words a diagram would also help.

Would not attempt changing the current config as much as first setting up a secure link.

Not to derail the discussion, but upon further reading I still think that what you actually want to do is what was described in my initial post. If not, sorry for bringing it up.

A network diagram properly labelled would certainly help.

If you are serious about this, I could spare one of my lab devices and give you access for a day or two...

Great offer by Lurker..................

@anav
Actually no need of highly specialized technicians, anyone can be instructed remotely.
Your mission, should you accept it, is to insert the green ethernet cable into Port #8.

NO! NOT the red one, you fool!
4
3
2
1

KABOOM![1]

[1]Note to recruitment: no more color blind agents, please.

You might be surprized to know that I get the wrong end of the usb cable more times than right the first time LOL. I think USB-C was invented for this reason.

I believe it was designed to allow insertion with any side up, unlike USB A or micro, or some other connectors (of course the easiest Is the audio jack or the round power plug, but only two or three contacts in them)

It Is a very handy feature for many people who have difficulties in vision, I never realized the importance of this until my mom made me notice how easier It was to connect her new phone for recharging, a clear step forward from her earlier (micro USB) one. (and a step back from good ol' Nokia)

We need more information from you, like does your WAN use DHCP, or manually configured static address & gateway, or PPPoE. Then we also need to know how you are remotely connected to the device, through VPN? Which one? I assume that the VPN connection needs the WAN connection of the router (you don't have a 2nd independent WAN through another router on the same site)?

If the router is the only available gateway to the internet, then while doing the remote configuration swap you shouldn't use SafeMode, because the WinBox connection will be shortly interrupted and SafeMode might undo everything!

As an example of how to proceed, let's assume that your current configuration is based on defconf with little modification, and that you use DHCP client or PPPoE Client on ether1, you have WireGuard running and use it to remotely access the router, this is how I would proceed:

  1. Upgrade to latest stable 7.19.4 version.

  2. Use WinBox to connect remotely with no SafeMode.

  3. Make sure all the other ports except for ether1 are in the main bridge (I think it's the default).

  4. Export current config with /export file=config and save config.rsc locally and open it with text editor.

  5. Create VLAN interface vlan-lan under /interface vlan with VLAN ID 200.

  6. Go to /interface bridge port and for ports ether2, ether3, ether4 set PVID to 200 and Frame Types to admit-only-untagged-and-priority-tagged.

  7. Find in the exported file (simple text search) things that reference the current bridge interface as interface, except for the things under the /interface bridge port and the /interface bridge sections. That means, you'll find DHCP server configurations, interface list member configurations, /ip address and /ipv6 address entries, etc.... Using WinBox, go to those entries and change places that reference bridge as interface to vlan-lan.

  8. Run /export file=config again, save and verify that bridge now only appears in the text file under /interface vlan, /interface bridge, and /interface bridge port, and that everywhere else it has been replaced with vlan-lan.

  9. Under /interface bridge, turn on vlan-filtering=yes for the main bridge interface. After this step your LAN has been moved from the bridge interface to the vlan-interface, is accessible on the three ether2, ether3, ether4 ports, while retaining every function.

  10. Under /interface vlan create a new VLAN interface vlan-wan with VLAN ID 100.

  11. Under /interface bridge port edit the entries of ether5, ether6, ether7, ether8 and change PVID to 100 and Frame Types to admit-only-untagged-and-priority-tagged.

  12. If your WAN on ether1 requires a particular MAC address (the one currently on ether1), create a MACVLAN interface under the interface vlan-wan with the name macvlan-wan and assign the MAC address of ether1 to it. Otherwise skip this step!

  13. Assuming that your config is based on defconf and that you already have an interface list WAN with ether1 as member. If not, create that interface list and add ether1 to it. Then add vlan-wan and macvlan-wan (if you did have to do step #12) to this WAN interface list. If you use PPPoE for your WAN with pppoe-out1 as interface, then make sure the pppoe-out1 interface is in this list too!

  14. Export current config with /export file=config again and open locally with text editor, search for occurrences of ether1 (and pppoe-out1 if applicable) in the file, ignoring sections like /interface ethernet and /interface bridge port.

    • If you find it in firewall rules, edit those rules and swap in-interface=ether1 with in-interface-list=WAN and swap out-interface=ether1 with out-interface-list=WAN.

    • If you use PPPoE with a pppoe-out1 interface, also look out for occurrences of pppoe-out1 in the firewall rules, and edit them, swapping in-interface=pppoe-out1 with in-interface-list=WAN and swap out-interface=pppoe-out1 with out-interface-list=WAN accordingly.

    • If your WAN uses DHCP client then find and duplicate the DHCP client entry, and for the new entry set the interface to vlan-wan if you didn't need step #12, or to macvlan-wan if you needed to do #12.

    • If your WAN uses PPPoE client then duplicate the pppoe-out1 entry to create a new pppoe-out2 entry with the same settings, with the exception that the underlying interface is vlan-wan (or macvlan-wan if you had to do step #12). Add this pppoe-out2 interface to the WAN list too!

    • For the other places that reference ether1 (or pppoe-out1) in the config file, except for the ones in the bridge-related, try to edit the entries and change the interface to interface list WAN if possible, or if not, make a copy and reference the new vlan-wan (or macvlan-wan) if needed. For some settings like IGMP proxy, if ether1 is the upstream interface then you have to edit the entry and swap ether1 with vlan-wan instead of making a copy because there can be only one upstream interface.

    • If you have scripts that do things with DHCP client/PPPoE client or ether1/pppoe-out1, modify them so that they apply to the newly created things above.

  15. Export current config again and verify that you've not missed anything.

  16. Now is the moment where you'll temporarily lose the remote access to the router. And maybe permanently if you did something wrong or missed something in the steps above!!!

    Go to /interface bridge port and create an entry to add ether1 to the main bridge bridge with PVID set to 100 and Frame Types to admit-only-untagged-and-priority-tagged.

    The moment you save the new entry, WinBox will disconnect. Hopefully, the second DHCP client or PPPoE client (configured on vlan-wan or macvlan-wan) should kick in and re-establish the WAN connection shortly, so that you can regain your remote access through WireGuard.

  17. If things work, export the config again and find the occurrences of ether1, you can now disable no longer used sections related to ether1 like the old DHCP client or PPPoE client entry (NOT the bridge or ethernet related sections!!!).

Maybe useful, maybe not (and shameless plug), the configuration parser and comparer spreadsheets may help you in getting a better overall vision of the settings and be useful to make the changes suggested by CGGXANNX, just in case:
Configuration Parser Spreadsheet
Terse export converter and config compare

Thanks for the detailed instructions. I'll give it a go. Although this will need to wait until next week when I get some time to work on it.
For reference, this particular router (B) is on a LAN that's created by an upstream router (A). I connect to A through a RaspberryPi I have left on that LAN. It runs a VPN (tailscale) that allows me to use Winbox to get to router-A. As for router-B (the one I'm going to operations on) I access it through its Wifi interface (from the RPi as well). I've managed to lock myself out of router-B once already a few weeks ago and had to have someone factory-reset it. That's not a procedure I can count on again.
Anyway, I think the instructions you left will do the trick.
Thanks much. Will keep you posted.
Cheers - BPC

Warning: what I wrote in the previous post was with the assumption (that I also stated in that post) that you enter the router "B" with WinBox through either its WAN interface (the one that uses ether1) or a VPN that uses the WAN interface. If you connect to the router "B" by a LAN-side interface (I assume that the WiFi interface of the L009UiGS-2HaxD is member of the LAN bridge), then do not proceed, because you'll lose access to router "B" at step 7!!!

If you confirm that you enter the router through its "LAN" side (the bridge interface), then I'll post the modifications of the steps above so that you don't lose access to the router!

The first thing I would do is at your home or office MT device, setup a wireguard interface ( assumes you have a public WANIP etc.)
Add your iphone or laptop to check connectivity through cellular or coffeshop.
Once up and running, the next time you are on your MT remote, set it up as a client.
Then you will have direct access to the router B and router A will be totally transparent.
Would use this for most config and your rasb pie as a backup.