If you are wanting to configure multiple MikroTik routers with the same configuration, or to copy a config from one router to another, the best way is to use an export. The export command dumps all of the configuration commands you added to a router to a text file and none of the stuff that gets you in trouble like MAC addresses. Then by using the import command, you can apply that set of commands to an unconfigured router. Issues with this method are often experienced if the target router has any configuration on it to begin with, even the default config, thereby causing the import to fail. Therefore, I always like to start with a fresh, blank router. Unfortunately, unconfigured routers can be problematic to connect to via the MAC address for some PC's. I have found a better way to accomplish this task. The following example is from my latest book RouterOS by Example, 2nd Edition:
Step 1 - Creating a Text Export on Router 1 The text export is created from the command line only:
- Open a terminal window by clicking the New Terminal button.
- At the root prompt, type /export compact file=[your file name here]. Of course, the square brackets are not actually typed, you should be naming your file in that field.
[admin@i4E] > export compact file=myrouterconfig.autoIt is not necessary to specify the file extension. The extension will be added automatically. Producing the export will take 100% CPU for a few seconds but will then produce a file in the Files List.
- From there you can drag and drop it to your desktop for renaming and further editing. You can also omit the “files=” portion of the command and it will export the configuration to the terminal window. From there you can copy and paste parts of the file for use elsewhere. Also note that the export is produced relative to the portion of the command tree you are in. For example, from the root of the command tree, you will export the entire configuration. By typing IP address and enter, you will then be inside the IP address menu branch and an export from there will only produce that portion of your configuration.
Step 2 - Upgrade and Import Assumptions:
- I have reset the router to the defaults using the reset switch or started with a router out of the box.
- In my lab, I have a DHCP server and network access that I will connect to the router on ether1. Since that port has a default config with DHCP client, it will pull an IP and have internet access.
- I will be using the default configuration which includes a complete base config and I am attaching my laptop with DHCP to ether2.
- Once everything boots, the laptop should have internet access through the defaulted router.
- Once the router is booted and the laptop has internet access, click System-Packages and the Check for Upgrades button and install any upgrades, router will reboot.
- After reboot, drag the script your created on Router1 myrouterconfig.auto.rsc into the Files list on Router2. You can even drag from one Winbox Files list to another Winbox window's files list, or drop it on your laptop desktop in between, your choice.
- Next, click System-Reset Configuration, check No Default Configuration and select the script you previously exported:
- Click Reset Configuration. The router will then reboot, erase itself and then import your custom configuration. This works very well when you have a stack of routers to upgrade and configure. Have fun.
Edited: 21 Dec 2020
In RouterOS it is possible to automatically execute scripts - your script file has to be named anything.auto.rsc - once this file is uploaded using FTP to the router, it will automatically be executed, just like with the '/import' command. This method only works with FTP.
Once the file is uploaded, it is automatically executed. Information about the success of the commands that were executed is written to anything.auto.log