Микротик сохранить конфигурацию роутера

Manual:Configuration Management

This manual introduces you with commands which are used to perform the following functions:

  • system backup;
  • system restore from a backup;
  • configuration export;
  • configuration import;
  • system configuration reset.

Description

The configuration backup can be used for backing up MikroTik RouterOS configuration to a binary file, which can be stored on the router or downloaded from it using FTP for future use. The configuration restore can be used for restoring the router’s configuration, exactly as it was at the backup creation moment, from a backup file. The restoration procedure assumes the configuration is restored on the same router, where the backup file was originally created, so it will create partially broken configuration if the hardware has been changed.

The configuration export can be used for dumping out complete or partial MikroTik RouterOS configuration to the console screen or to a text (script) file, which can be downloaded from the router using FTP protocol. The configuration dumped is actually a batch of commands that add (without removing the existing configuration) the selected configuration to a router. The configuration import facility executes a batch of console commands from a script file.

System reset command is used to erase all configuration on the router. Before doing that, it might be useful to backup the router’s configuration.

System Backup

The system backup feature allows you to effortlessly save and load device’s configuration. Read more about the backup feature in the System/Backup section.

Exporting Configuration

Command name: /export

The export command prints a script that can be used to restore configuration. The command can be invoked at any menu level, and it acts for that menu level and all menu levels below it. The output can be saved into a file, available for download using FTP.

Command Description

Example

[admin@MikroTik] > ip address print Flags: X - disabled, I - invalid, D - dynamic # ADDRESS NETWORK BROADCAST INTERFACE 0 10.1.0.172/24 10.1.0.0 10.1.0.255 bridge1 1 10.5.1.1/24 10.5.1.0 10.5.1.255 ether1 [admin@MikroTik] >
[admin@MikroTik] ip address> export file=address [admin@MikroTik] ip address>

To see the files stored on the router:

[admin@MikroTik] > file print # NAME TYPE SIZE CREATION-TIME 0 address.rsc script 315 dec/23/2003 13:21:48 [admin@MikroTik] >

Compact Export

Starting from v5.12 compact export was added. It allows to export only part of configuration that is not default RouterOS config.

Note: Starting from v6rc1 «export compact» is default behavior. To do old style export use export verbose

For example compact OSPF export:

[admin@SXT-ST] /routing ospf> export compact # jan/02/1970 20:16:32 by RouterOS 5.12 # software ospf instance set [ find default=yes ] redistribute-connected=as-type-1 /routing ospf interface add disabled=yes interface=wlan1 network-type=point-to-point /routing ospf network add area=backbone network=10.255.255.36/32 add area=backbone disabled=yes network=10.5.101.0/24 add area=backbone network=10.10.10.0/24 [admin@SXT-ST] /routing ospf>

Compact export introduces another feature that indicates which part of config is default on RouterOS and cannot be deleted. As in example below ‘*’ indicates that this OSPF instance is part of default configuration.

[admin@SXT-ST] /routing ospf instance> print Flags: X - disabled, * - default 0 * name="default" router-id=0.0.0.0 distribute-default=never redistribute-connected=as-type-1 redistribute-static=no redistribute-rip=no redistribute-bgp=no redistribute-other-ospf=no metric-default=1 metric-connected=20 metric-static=20 metric-rip=20 metric-bgp=auto metric-other-ospf=auto in-filter=ospf-in out-filter=ospf-out

List of default config by menus that cannot be removed:

Читайте также:  Wifi роутер орион телеком
Menu Entries
/interface wireless security-profiles default
/ppp profile «default», «default-encryption»
/ip hotspot profile «default»
/ip hotspot user profile «default»
/ip ipsec proposal «default»
/ip smb shares «pub»
/ip smb users «guest»
/ipv6 nd «all»
/mpls interface «all»
/routing bfd interface «all»
/routing bgp instance «default»
/routing ospf instance «default»
/routing ospf area «backbone»
/routing ospf-v3 instance «default»
/routing ospf-v3 area «backbone»
/snmp community «public»
/tool mac-server mac-winbox «all»
/tool mac-server «all»
/system logging «info», «error», «warning», «critical»
/system logging action «memory», «disk», «echo», «remote»
/queue type «default», «ethernet-default», «wireless-default», «synchronous-default», «hotspot-default», «only-hardware-queue», «multi-queue-ethernet-default», «default-small»

Importing Configuration

Command name: /import

The root level command /import [file_name] executes a script stored in the specified file. It will add the configuration from the specified file to an existing configuration. This file may contain any console commands, including scripts. Can be used to restore configuration or parts of it after configuration loss.

Command Description

Automatic Import

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

Example

To load the saved export file use the following command:

[admin@MikroTik] > import address.rsc Opening script file address.rsc Script file loaded and executed successfully [admin@MikroTik] >

Configuration Reset

Command name: /system reset-configuration

Description

The command clears all configuration of the router and sets it to the default including the login name and password (‘admin’ and no password), IP addresses and other configuration is erased, interfaces will become disabled. After the reset command router will reboot. The default is either the factory default, that you can see in the article Default configurations, or it can be a custom default, that can be loaded by including an RSC file when doing Netinstall or if specified with a branding package.

Command Description

  • keep-users: keeps router users, passwords and ssh host keys(since v6.45.1)
  • no-defaults: doesn’t load any default cofigurations, just clears everything
  • skip-backup: automatic backup is not created before reset, when yes is specified
  • run-after-reset: specify export file name to run after reset
Читайте также:  Тп линк роутер где посмотреть пароль

Note: If run-after-reset is set then no-defaults parameter will be ignored and only the specified script will be loaded!

Warning: Warning: If the device has a folder named «flash», then the confscript.rsc file must be stored in that folder to work with «run-after-reset» command. Everything outside this folder is stored on the RAM drive which contents are deleted on reboot or power cycle.

Warning: If the router has been installed using netinstall and had a script specified as the initial configuration, the reset command executes this script after purging the configuration. To stop it doing so, you will have to reinstall the router.

Example

[admin@MikroTik] > system reset-configuration Dangerous! Reset anyway? [y/N]: n action cancelled [admin@MikroTik] >

Import troubleshooting

Configuration parts to watch out for in exported .rsc files

Things that should be removed from export files that were created with: «/export», before attempting import on new device.

/interface ethernet set [ find default-name=ether5 ] auto-negotiation=no name=ether1-gateway set [ find default-name=ether6 ] name=ether2 set [ find default-name=ether7 ] name=ether3 set [ find default-name=ether8 ] name=ether4 set [ find default-name=ether1 ] name=ether5 set [ find default-name=ether2 ] name=ether6 set [ find default-name=ether3 ] name=ether7 set [ find default-name=ether4 ] name=ether8
  • In older version exports default entries might show with «add» instead of «set» command. That should be edited before import to avoid errors.
  • Check if interface/module: ether/wlan/modem/com/etc count match on new and old device. If there will some missing that will end up in error during .rsc import.

In case of problematic import, attempt the following:

  • Reset the configuration on that device.
  • Run import command again with «verbose=yes» argument. It will stop also stop import process on problem which you already encountered, but will also show place where export failed. That way showing you place where things need to be edited in .rsc import file

Startup delay

If your configuration relies on interfaces that might not yet have started up upon command execution, it is suggested to introduce delays, or to monitor until all needed interfaces are available. This example script allows you to set how many interfaces you are expecting, and how long to wait until they become available:

The above script will wait until there are 10 interfaces visible, or 30 seconds. If there are no 10 interfaces in this time, it will put a message in the log. Modify the variables according to your needs.

Источник

Как сохранить конфигурацию MikroTik

Что бы сохранить конфигурацию MikroTik существует несколько способов и сейчас мы их рассмотрим:

Если вы ищете понятный и удобный источник информации по микротикам, то вот он: курс «Настройка оборудования MikroTik». Это видеоучебник, где «без воды» собрана вся базовая информация по работе с MikroTik и RouterOS. Для новичков станет прямым руководствам, опытные инженеры смогут освежить и упорядочить знания. 162 видеоурока и 45 лабораторных работ, основанные на программе вендора MTCNA. Первые 25 уроков можно заказать бесплатно на странице курса.

Читайте также:  Tp link роутеры все модели

1. Самый простой способ, это воспользоваться утилитой WinBox.

Для этого откроем меню Files и нажмем Backup.

В поле Name пишем название нашей резервной копии, при желании можем зашифровать введя пароль в поле Password, если пароль не требуется, ставим галочку Don’t Encrypt и нажимаем на кнопку Backup. После этого в списке файлов появится наша резервная копия. Что бы сохранить резервную копию к себе на компьютер, перетащите файл мышкой к себе на локальный диск.

Что бы восстановить резервную копию, выбираем файл и нажимаем Restore.

Перед восстановлением сбросьте все настройки через меню System -> Reset Configuration.

2. Сохранение резервной копии через терминал.

Зайдите в терминал через меню New Terminal и введите команду:

system backup save name=Backup_term (имя можно придумать любое)

После чего появится надпись:

Saving system configuration
Configuration backup saved

и в списке файлов будет наша резервная копия

Что бы восстановить резервную копию, введите команду:

system backup load name=Backup_term

Настройки будут восстановлены из файла Backup_term

3. Сохранение настроек в текстовом формате.

Настройки вашего устройства можно сохранить так же и в текстовом формате. Это удобно если требуется сравнить 2 конфигурации или изменить какие то настройки.

Что бы сохранить настройки в текстовом формате зайдите в New Terminal и введите команду:

После выполнения команды появится в файлах сохраненная наша конфигурация

Что бы восстановить конфигурацию, введите команду:

Иногда встречаются ситуации, когда требуется сохранить только часть настроек, например настройки dhcp сервера, правила и тд, для этого существуют следующие команды:

ip address export file=ip.rsc
ip firewall mangle export file=mangle.rsc
ip firewall nat export file=nat.rsc
ip firewall filter export file=filter.rsc
queue simple export file=simple.rsc
ip dns export file=dns.rsc
files backup export file=backup.rsc
system script export file=script.rsc
system scheduler export file=scheduler.rsc
tool e-mail export file=email.rsc
ip firewall address-list export file=address-list.rsc
ip route export file=route.rsc
ip dhcp-server network export file=network.rsc
queue type export file=type.rsc
queue tree export file=tree.rsc
queue simple export file=simple.rsc
interface ethernet export file=ethernet.rsc
ip pool export file=pool.rsc
ppp profile export file=profile.rsc
log export file=log.rsc

Если вы ищете понятный и удобный источник информации по микротикам, то вот он: курс «Настройка оборудования MikroTik». Это видеоучебник, где «без воды» собрана вся базовая информация по работе с MikroTik и RouterOS. Для новичков станет прямым руководствам, опытные инженеры смогут освежить и упорядочить знания. 162 видеоурока и 45 лабораторных работ, основанные на программе вендора MTCNA. Первые 25 уроков можно заказать бесплатно на странице курса.

Источник

Оцените статью
Adblock
detector