I asked an AI and here are the answers. I’m posting the proposed solutions here in case it can help someone else in the future.
Here is the answer (PART 1) I got from the AI:
On MikroTik x86 systems (including CHR), interface names can swap after reboots because RouterOS assigns names based on the order the kernel detects the PCI devices, which isn't always consistent.
To fix this, you must bind the interface names to their MAC addresses using a script that runs on startup.
Steps to Lock Interface Names
-
Identify your MAC addresses: Go to the Interfaces menu in WinBox and note the MAC address for each physical card.
-
Create a Startup Script: Navigate to System > Scripts and add a new script (e.g., interface-fixer) with the following logic:
In a follow up question (PART 2), I asked to expand the script for LAN, WAN and MGMT ports.
To ensure your interfaces always map to the correct roles regardless of the boot order, we will create a script that checks every physical interface against a list of known MAC addresses and renames them accordingly.
Step 1: Map Your Hardware
First, identify the MAC addresses printed on your hardware or found in /interface ethernet print.
| Desired Name |
MAC Address (Example) |
| WAN |
AA:BB:CC:11:22:33 |
| LAN |
AA:BB:CC:44:55:66 |
| MGMT |
AA:BB:CC:77:88:99 |
Step 2: The Logic Script
Go to System > Scripts in WinBox, create a new script named fix-interfaces, and paste the following code.
Note: This script uses a "temporary name" step. This prevents errors if you try to rename an interface to "WAN" while another interface is currently holding that name.
routeros
{
# 1. Define your MAC-to-Name mapping
:local mapping {"AA:BB:CC:11:22:33"="WAN"; "AA:BB:CC:44:55:66"="LAN"; "AA:BB:CC:77:88:99"="MGMT"}
# 2. First pass: Rename interfaces to temporary names to avoid naming conflicts
:foreach mac,name in=$mapping do={
:local iface [/interface ethernet find where mac-address=$mac]
:if ([:len $iface] > 0) do={
/interface ethernet set $iface name=("temp-" . $name)
}
}
# 3. Second pass: Set final names
:foreach mac,name in=$mapping do={
:local iface [/interface ethernet find where mac-address=$mac]
:if ([:len $iface] > 0) do={
/interface ethernet set $iface name=$name
}
}
:log info "Interface names have been synchronized by MAC address."
}
Use code with caution.
Step 3: Automate at Boot
To ensure this runs every time the x86 hardware re-indexes the PCI bus, set up a scheduler task:
-
Navigate to System > Scheduler.
-
Click Add New.
-
Name: apply-interface-fix.
-
Start Time: startup.
-
On Event: fix-interfaces (or paste the script code directly here).
-
Policy: Ensure read, write, and test are checked.
Important Considerations
-
Existing Configurations: If you already have IP addresses, Firewall rules, or DHCP servers assigned to names like ether1, they will break once the name changes to WAN. You will need to update those references to point to the new names.
-
Virtual Environments: If you are running this on Proxmox or VMware, ensure the "Network Card" settings in the VM hardware use Static MAC addresses rather than dynamic ones.
In a follow up question (PART 3), I asked to expand the answer that the same CLI configuration files could be used on 2 different X86 RouterOS.
Step 1: Set the Identities
Run these commands on each respective router so the script knows which hardware it is currently running on.
Step 2: The Multi-Router Script
This script uses a conditional check to load the correct MAC address mapping based on the Router Identity.
routeros
{
:local routerName [/system identity get name];
:local mapping;
# Define MAC mappings for each specific router
:if ($routerName = "R1") do={
:set mapping {"AA:11:11:11:11:11"="WAN"; "AA:22:22:22:22:22"="LAN"; "AA:33:33:33:33:33"="MGMT"}
} else={
:if ($routerName = "R2") do={
:set mapping {"BB:11:11:11:11:11"="WAN"; "BB:22:22:22:22:22"="LAN"; "BB:33:33:33:33:33"="MGMT"}
}
}
# Pass 1: Rename to temporary names (avoids "already exists" errors)
:foreach mac,name in=$mapping do={
:local iface [/interface ethernet find where mac-address=$mac]
:if ([:len $iface] > 0) do={
/interface ethernet set $iface name=("temp-" . $name)
}
}
# Pass 2: Set final names
:foreach mac,name in=$mapping do={
:local iface [/interface ethernet find where mac-address=("temp-" . $name)]
:if ([:len $iface] > 0) do={
/interface ethernet set $iface name=$name
}
}
:log info ("Interface names synchronized for router: " . $routerName)
}
Use code with caution.
Implementation Tips
-
Update MACs: Replace the placeholder AA:... and BB:... values with the actual MAC addresses for your two x86 boxes.
-
Scheduler: As before, ensure this script is added to the System Scheduler with the startup policy so it fixes the names immediately after a reboot.
-
Safety: If you have more than 3 interfaces, the unmapped ones will keep their default names (e.g., ether4).
Cheers!