How to Create a Bridge on MikroTik to Combine Ports

Aisyah Aldina

Illustration of a bridge for a guide on how to create a bridge on MikroTik to combine ports

Hi everyone, in this post I want to show you how to create a bridge on MikroTik to combine ports. A bridge is a virtual interface that joins several physical ports into one layer 2 network. Devices plugged into different ports stay on the same segment, get their IP from the same DHCP server, and can talk to each other as if they were connected to a single switch.

This article continues the earlier posts in the series, MikroTik basic configuration with Winbox for beginners and how to set up a MikroTik DHCP server. The lab is a MikroTik CHR running RouterOS 7.25.2 in VirtualBox. Until now only ether2 was the LAN, with the IP 192.168.56.10 and the DHCP server dhcp1. This time ether3 joins the same network. I also ran into two real problems while doing it: WinBox disconnected and Safe Mode rolled everything back, and clients on different ports could not ping each other in VirtualBox. I cover both of them here, along with the fixes.

What Is a MikroTik Bridge

Put simply, a MikroTik bridge is a virtual switch inside the router. Ports added to the bridge forward frames to each other based on MAC addresses, just like a regular switch. As a result, the IP address and the DHCP server are no longer set on each port individually, but on the bridge interface.

Before bridge : ether2 = 192.168.56.0/24, ether3 = unused
After bridge  : bridge1 = 192.168.56.0/24, ports ether2 + ether3

A few things worth knowing before you start:

Protocol Mode  : RSTP by default, prevents loops if cables form a circle
Admin MAC      : a fixed MAC for the bridge so it does not keep changing
master-port    : the old RouterOS 6 method, replaced by bridge since 6.41

On physical routers such as the hEX or RB4011, bridge ports usually carry the H flag, which means hardware offload is active. Forwarding is handled by the switch chip, so it does not load the CPU. On a CHR the H flag does not appear because there is no switch chip, so the CPU does all the forwarding.

The Situation Before the Bridge

Check the port you want to add

MikroTik Interfaces list with ether3 still unused

Click Interfaces and make sure ether3 is in the list. In this lab ether3 is connected to a second client VM through a VirtualBox Internal Network, but it has no IP and no DHCP server yet.

The client on ether3 has no IP yet

Client on ether3 has no IP yet, so ping to the router fails with Network is unreachable
ip -4 addr show enp0s3; ping -c 2 192.168.56.10

The client plugged into ether3 gets no IP at all, so pinging the router fails with the message Network is unreachable. This is exactly what the bridge is going to fix.

Creating a Bridge on MikroTik

Create a new bridge interface

Creating a new bridge1 interface with an Admin MAC Address in WinBox

Click Bridge, then click New. Set Name to bridge1. In Admin. MAC Address, enter the MAC of ether2, which in this lab is 08:00:27:CF:9E:9F. Click OK.

The MikroTik documentation recommends setting an Admin MAC. Without it, the bridge automatically takes the MAC of one of its ports, and that MAC can change when ports are added or removed. Clients may then lose their connection for a moment because their ARP entry still points to the old MAC, and a WinBox session over MAC can drop too. Using the MAC of ether2 also means clients keep seeing the same router MAC they saw before the bridge existed.

Check that bridge1 was created

bridge1 has been created with Protocol Mode RSTP

bridge1 shows up with Protocol Mode RSTP and a MAC Address matching the Admin MAC. Here is the terminal version of this step:

/interface bridge add name=bridge1 admin-mac=08:00:27:CF:9E:9F auto-mac=no

Replace the MAC with the MAC of ether2 on your own router. You can find it under Interfaces by double clicking ether2.

Add ether3 to the bridge

Adding ether3 as a port of bridge1 from the Ports tab

Click the Ports tab, then New. Choose Interface ether3 and Bridge bridge1, then click OK. An unused port is safe to add first because it does not cut any existing connection.

Check the ether3 port

ether3 is now a bridge1 port with the designated port role

ether3 is now a port of bridge1 with the role designated port and Forwarding yes, which means the port is actively forwarding traffic.

Moving ether2 to the Bridge Without Losing Access

This is the part where beginners most often lock themselves out of the router. As soon as ether2 joins the bridge, the IP 192.168.56.10 that is still assigned to ether2 stops working, because a bridge port should not hold its own IP. Until the IP and the DHCP server move to bridge1, the router cannot be reached from the LAN.

First attempt with Safe Mode

WinBox shows Connection lost when ether2 is added to the bridge in Safe Mode

I turned on Safe Mode and then added ether2 as a port of bridge1 from WinBox. Connection lost appeared immediately and WinBox started trying to reconnect. The WinBox session, which was connected over the MAC address, dropped as well because ether2 had moved into the bridge.

Safe Mode rolls back the changes

Safe Mode rolls back the change, so the IP and DHCP server return to ether2
/ip address print where interface~"ether2|bridge1"
/ip dhcp-server print

After about half a minute, WinBox reconnected. The bridge ports only contained ether3, and the IP and dhcp1 were back on ether2. Safe Mode did its job correctly: the admin connection was lost, so every change made since Safe Mode was turned on got undone. You can read how it works in the article on how to use MikroTik Safe Mode.

My experience: This confused me for a moment, because the ether3 change I made before Safe Mode was still there, while ether2 had disappeared from the ports. It turns out that is by design. Safe Mode only undoes changes made while Safe Mode is active. So Safe Mode is not a good fit when you move the very port you are using for remote access, because the session will definitely drop and the change will definitely be rolled back.

Move everything in a single line

IP address and DHCP server moved to bridge1 with ports ether2 and ether3

The fix is to run three commands together on one line in New Terminal, without Safe Mode. The router executes them in order within milliseconds, so by the time ether2 joins the bridge, the IP and the DHCP server are already waiting on bridge1.

/ip address set [find address="192.168.56.10/24"] interface=bridge1; /ip dhcp-server set dhcp1 interface=bridge1; /interface bridge port add bridge=bridge1 interface=ether2

Then check the result.

/ip address print where interface~"ether2|bridge1"
/ip dhcp-server print
/interface bridge port print

The IP 192.168.56.10/24 is now on bridge1, dhcp1 is on bridge1 too, and the bridge ports contain both ether3 and ether2. WinBox reconnected briefly and came right back.

Update the firewall rules

The allow from LAN firewall rule changed from ether2 to bridge1

Firewall rules that use in-interface=ether2 will no longer match, because LAN traffic now enters through bridge1. In this lab, the rule that allows traffic from the LAN, created in the basic configuration article, needs to be changed.

/ip firewall filter set [find in-interface=ether2] in-interface=bridge1
/ip firewall filter print where chain=input

Rule number 2 now reads in-interface=bridge1. If you use a LAN interface list, change its member from ether2 to bridge1 as well.

Testing Clients on Different Ports

The ether3 client gets an IP

Client on ether3 gets IP 192.168.56.102 but ping to the other client still fails
ip -4 addr show enp0s3 | grep inet; ip route | head -1; ping -c 3 192.168.56.101

The client on ether3 now gets the IP 192.168.56.102 and the gateway 192.168.56.10 from dhcp1. However, pinging the first client on ether2, which has the IP 192.168.56.101, still fails with Destination Host Unreachable.

This problem is specific to the VirtualBox lab. By default, a virtual adapter rejects frames that are not addressed to its own MAC. The MikroTik bridge needs to forward frames meant for other clients’ MACs, so VirtualBox simply drops them. You will not see this problem on a physical router.

Change Promiscuous Mode in VirtualBox

Changing the VirtualBox adapter Promiscuous Mode to Allow All

Open the Settings of the MikroTik VM, choose Network, and on Adapter 2 and Adapter 3 set Promiscuous Mode to Allow All. Click OK. If the VM is running, you can also do it from the Command Prompt on Windows:

VBoxManage controlvm "MikroTik CHR" nicpromisc2 allow-all
VBoxManage controlvm "MikroTik CHR" nicpromisc3 allow-all

After that, unplug and replug the virtual cable once by unchecking Virtual Cable Connected and checking it again, so the setting takes effect right away.

Ping between clients works

Ping from the ether3 client to the ether2 client succeeds with 0 percent packet loss
ping -c 3 192.168.56.101

The client on ether3 can now ping the client on ether2 with 0% packet loss and times under 1 ms. Both clients are now on one layer 2 network through bridge1.

See client MACs in the Hosts tab

Bridge Hosts tab showing the client MAC addresses on ether3 and ether2

Click the Hosts tab in the Bridge window. Here you can see which MAC address was learned on which port. The second client’s MAC is listed on ether3, and the first client’s MAC is listed on ether2. Entries with the L flag are the router’s own MACs. This tab is very useful for tracking down which port a device is plugged into.

The ether3 client can reach the internet

Client on ether3 successfully pings google.com through bridge1
ping -c 3 google.com

Because the NAT masquerade rule from the NAT article uses out-interface-list=WAN, the client on the new port gets internet access right away without any changes. The name google.com is also resolved successfully by the router’s DNS.

Common Problems and How to Fix Them

WinBox disconnects and cannot log in again after creating the bridge

The IP is still on the old port, while that port has already joined the bridge. Log in using the MAC address from the WinBox Neighbors tab, then move the IP to the bridge with /ip address set. If even MAC login fails, use a port that is not part of the bridge, or the console.

Clients do not get an IP after the port joins the bridge

The DHCP server is still assigned to the old interface. Check it with /ip dhcp-server print, then change the interface to bridge1.

A loop message appears or a port shows discarding

RSTP has detected a circular path, for example two bridge ports plugged into the same switch. Unplug one of the cables. Do not turn off RSTP, because a loop can bring down the entire network.

Clients on different ports cannot ping each other in VirtualBox or GNS3

Enable Promiscuous Mode Allow All on the router VM’s adapters, as shown in the step above.

The bridge is slow on an older router

Make sure the bridge ports use hardware offload with the H flag. Hardware offload can be disabled when certain features are in use, such as the bridge firewall or ports from different switch chips. Check it under Bridge, Ports tab, HW column.

That is it, ether2 and ether3 are now combined in bridge1 with one gateway IP and one DHCP server, and clients on both ports can talk to each other. In the next article we will cover MikroTik static routing to connect networks on different subnets. If you have ever locked yourself out of a router while creating a bridge, feel free to share your story in the comments below.

Leave a Comment