Community discussions

MikroTik App
 
ejmerkel
newbie
Topic Author
Posts: 33
Joined: Wed Jun 03, 2009 8:26 pm

RANCID Config Backup

Mon Jun 15, 2009 8:04 pm

Has anyone gotten RANCID (http://www.shrubbery.net/rancid/) to work with Mikrotik Routers?

It looks like someone has attempted this (http://www.gossamer-threads.com/lists/rancid/users/3826) but I've not had any luck getting his patch to work.

If anyone has this working, please let me know. I could use some tips.
 
rnsvi
just joined
Posts: 3
Joined: Wed Jul 01, 2009 3:41 pm

Re: RANCID Config Backup

Wed Jul 01, 2009 3:45 pm

I was able to get Rancid updated so that it will login properly & get the configs.
However, it seems to only fully work when you manually run it.

Something about the automatic running is causing an error.
Trying to get all of the configs.
br1.prn: missed cmd(s): system routerboard print
It tries 4 times, then quits and never actually saves the config.

But if you use
rancid-run -r <router-name>
It runs just fine and gets all the changes.

Anybody else seen this behavior?

*Update: Oh, I forgot to mention it only works with version 3.x because the login script is adding +ct to the end of the username. Which in 3.x turns color off, and automatic tabbing maybe? 2.9 doesn't know what to do with that, so it just assumes your username is wrong.

-Keith-
RNS
 
falz
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Tue Jun 03, 2008 10:54 pm

Re: RANCID Config Backup

Thu Nov 18, 2010 7:10 pm

Chiming in that that patch works fine for me, tested on routerboards running 4.11. It doesn't patch cleanly against the current version so I wrote a little page and have the files available for download here:

* Docs: http://falz.net/tech/rancid-mikrotik
* Files: http://falz.net/static/rancid/

One thing I notice is that RouterOS seems to randomly generate the mac address that's listed under /interface ovpn-server server even though I'm not using it and that's causing the config to be different each time.

Note that my above files and instructions are for FreeBSD, paths to where to put them may be different on your system. Also the paths to perl and expect at the beginning of each file may vary slightly as well.
 
rnsvi
just joined
Posts: 3
Joined: Wed Jul 01, 2009 3:41 pm

Re: RANCID Config Backup

Thu Nov 18, 2010 10:33 pm

You are correct about the ovpn thing. That plagued me for a bit.
I found that if you set a bogus mac, it stops. And doesn't actually turn on the ovpn-server
/interface ovpn-server server set mac-address=00:00:00:00:00:01
-Keith-
 
falz
Frequent Visitor
Frequent Visitor
Posts: 56
Joined: Tue Jun 03, 2008 10:54 pm

Re: RANCID Config Backup

Thu Nov 18, 2010 11:53 pm

Thanks, makes sense. For what it's worth I joined the RANCID mailing list to post a request to add their patch to be official. It may gain more traction if other Mikrotik+RANCID users were to chime in and say they use this functionality.

* http://www.shrubbery.net/pipermail/ranc ... 05362.html
 
timoid
newbie
Posts: 39
Joined: Tue Jan 01, 2008 8:20 am

Re: RANCID Config Backup

Mon Mar 07, 2011 6:27 pm

change:

{'system package print detail' => "SystemPackagePrintDetail"},

to

{'system package print detail without-paging' => "SystemPackagePrintDetail"},
 
pnep
just joined
Posts: 3
Joined: Mon Mar 21, 2011 9:01 am

Re: RANCID Config Backup

Mon Mar 21, 2011 9:09 am

Hello

mtrancid stoped parsing if mikrotik script have
] > "
.

example:
test@MikroTik_1000] > system script export
add name=timeout_winbox policy=ftp,reboot,read,write,policy,test,winbox,password,sniff,sensitive source=":log error(\"test\
    );\r\
.
.
               [:len [:find [/ip firewall connection get $c dst-address] (":" . [/ip service get winbox port])]] > 0) do={
.
.
Last edited by pnep on Mon Mar 21, 2011 1:20 pm, edited 3 times in total.
 
pnep
just joined
Posts: 3
Joined: Mon Mar 21, 2011 9:01 am

Re: RANCID Config Backup

Mon Mar 21, 2011 1:09 pm

how about
$prompt = "\\[9999B\\[\\w+\@\\w+\\] >\\s*";  # crude but effective
?
 
pnep
just joined
Posts: 3
Joined: Mon Mar 21, 2011 9:01 am

Re: RANCID Config Backup

Tue Mar 22, 2011 12:58 pm

+ if mtlogin output have:
   \n/export file=([/system identity get name] . \"-\" . [:pick [/system cloc\^
    k get date] 7 11] . [:pick [/system clock get date] 0 3] . [:pick [/system\^
or
add comment="" disabled=no down-script=":foreach i in=[/ip route find (static \^
    gateway=10.10.3.13 dst-address=192.168.0.0/24)] \\ do={/ip route disable \^
mtrancid output:
/system cloc k
and
staticgateway=10.10.3.13


how about
# RouterOS splits long lines with backslashes - this joins them back up
if (/\\\n$/) {
s/\\\n$//;
$buffer .= $_;
if (!/=$/ && !/="[^"]+$/ ) {
$buffer .= "";
}
}
 
risipetillo
Frequent Visitor
Frequent Visitor
Posts: 63
Joined: Tue Feb 03, 2009 7:08 pm

Re: RANCID Config Backup

Wed Mar 23, 2011 4:49 am

I followed the installation steps on the internet however, I'm having problems getting Rancid to recognize the "mikrotik" router name I created.

Any help would be greatly appreciated. Below is the error I'm recieving:

-bash-3.1$ more mikrotik.20110322.213618
starting: Tue Mar 22 21:36:18 CDT 2011



Trying to get all of the configs.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 1.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 2.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 3.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 4.
exec failed router manufacturer mikrotik: No such file or directory

cvs diff: Diffing .
cvs diff: Diffing configs
cvs commit: Examining .
cvs commit: Examining configs

ending: Tue Mar 22 21:36:18 CDT 2011


***********************************************************************

-bash-3.1$ cat var/mikrotik/router.db
172.16.0.254:mikrotik:up


***********************************************************************

%vendortable = (
'agm' => 'agmrancid',
'alteon' => 'arancid',
'arista' => 'arrancid',
'avocent' => 'avorancid',
'baynet' => 'brancid',
'cat5' => 'cat5rancid',
'cisco' => 'rancid',
'cisco-nx' => 'nxrancid',
'cisco-xr' => 'xrrancid',
'css' => 'cssrancid',
'enterasys' => 'rivrancid',
'erx' => 'jerancid',
'extreme' => 'xrancid',
'ezt3' => 'erancid',
'f5' => 'f5rancid',
'force10' => 'f10rancid',
'fortigate' => 'fnrancid',
'foundry' => 'francid',
'hitachi' => 'htrancid',
'hp' => 'hrancid',
'juniper' => 'jrancid',
'mikrotik' => 'mtrancid',
'mrtd' => 'mrancid',
'mrv' => 'mrvrancid',
'netopia' => 'trancid',
'netscaler' => 'nsrancid',
'netscreen' => 'nrancid',
'procket' => 'prancid',
'redback' => 'rrancid',
'riverstone' => 'rivrancid',
'smc' => 'srancid',
'tnt' => 'tntrancid',
'zebra' => 'zrancid',
'mikrotik' => 'mtrancid'
);
 
garlicbulb
Frequent Visitor
Frequent Visitor
Posts: 51
Joined: Mon Jul 25, 2011 12:41 am

Re: RANCID Config Backup

Mon Jul 25, 2011 12:43 am

Check the first line of mtrancid and mtlogin. They need to point to perl and expect on your system. The values that come with the scripts are probably nor right for your system.
 
omally01
newbie
Posts: 26
Joined: Mon Mar 07, 2011 10:08 pm

Re: RANCID Config Backup

Thu Sep 08, 2011 9:57 pm

First off thanks for all the info that was here already, it has helped a lot. I have gotten everything situated and I am stumped on a fairly simple spot, what syntax do you use to define the password for the mikrotik? No one seems to have covered that, do I define it just like the cisco passwords even though there is no "enable" password? Thanks in advance!
 
Beccara
Long time Member
Long time Member
Posts: 606
Joined: Fri Apr 08, 2005 3:13 am

Re: RANCID Config Backup

Sun Sep 25, 2011 11:31 pm

Going to necro this thread back to life,

I've gotten rancid running and pulling back from a 4.16 route but the diff's seems to show alot more than whats just changed
  /interface wireless manual-tx-power-table
- set Edge comment="" manual-tx-powers="1Mbps:17,2Mbps:17,5.5Mbps:17,11Mbps:17,6Mbps:17,9Mbps:17,12Mbps:17,18Mbps:17,24Mbps:17,36Mbps:17,48Mbps:17,54Mbps: 17,HT20-0:0,HT20-1:0,HT20-2:0,HT20-3:0,HT20-4:0,HT20-5:0,HT20-6:0,HT20-7:0 ,HT40-0:0,HT40-1:0,HT40-2:0,HT40-3:0,HT40-4:0,HT40-5:0,HT40-6:0,HT40-7:0"
+ set Edge comment="" 
+ manual-tx-powers=1Mbps:17,2Mbps:17,5.5Mbps:17,11Mbps:17,6Mbps:17,9Mbps
+ :17,12Mbps:17,18Mbps:17,24Mbps:17,36Mbps:17,48Mbps:17,54Mbps:17,HT20-0
+ :0,HT20-1:0,HT20-2:0,HT20-3:0,HT20-4:0,HT20-5:0,HT20-6:0,HT20-7:0,HT40
+ -0:0,HT40-1:0,HT40-2:0,HT40-3:0,HT40-4:0,HT40-5:0,HT40-6:0,HT40-7:0
It seems to be splitting up some commands at random across lines thus causing a diff, Anyone got any ideas on this?
 
timoid
newbie
Posts: 39
Joined: Tue Jan 01, 2008 8:20 am

Re: RANCID Config Backup

Mon Sep 26, 2011 12:39 am

Does it only happen if you run a backup by hand then later by the cron job?

I used to see this happen if ssh detected my terminal width - I only let the cron job do my backups now.
 
Beccara
Long time Member
Long time Member
Posts: 606
Joined: Fri Apr 08, 2005 3:13 am

Re: RANCID Config Backup

Mon Sep 26, 2011 1:43 am

Interesting point, I've run this both time in that diff by ./rancid-run in SSH, I'll let cron take over and see
 
DynStatic
Frequent Visitor
Frequent Visitor
Posts: 92
Joined: Thu Feb 18, 2010 3:11 am

Re: RANCID Config Backup

Fri Dec 02, 2011 6:08 am

It's not that the name is not being recognized, it's that the scripts it's running have errors in the first line which produce "No such file or directory". Run mtlogin and mtrancid manually and address those issues. Then it should work.

I had to change the following in Falz's scripts for Debian 6:

mtlogin:
#! /usr/local/bin/expect --
to
#! /usr/bin/expect --

mtrancid:
#! /usr/bin/perl5
to
#! /usr/bin/perl
I followed the installation steps on the internet however, I'm having problems getting Rancid to recognize the "mikrotik" router name I created.

Any help would be greatly appreciated. Below is the error I'm recieving:

-bash-3.1$ more mikrotik.20110322.213618
starting: Tue Mar 22 21:36:18 CDT 2011



Trying to get all of the configs.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 1.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 2.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 3.
exec failed router manufacturer mikrotik: No such file or directory
=====================================
Getting missed routers: round 4.
exec failed router manufacturer mikrotik: No such file or directory

cvs diff: Diffing .
cvs diff: Diffing configs
cvs commit: Examining .
cvs commit: Examining configs

ending: Tue Mar 22 21:36:18 CDT 2011


***********************************************************************

-bash-3.1$ cat var/mikrotik/router.db
172.16.0.254:mikrotik:up


***********************************************************************

%vendortable = (
'agm' => 'agmrancid',
'alteon' => 'arancid',
'arista' => 'arrancid',
'avocent' => 'avorancid',
'baynet' => 'brancid',
'cat5' => 'cat5rancid',
'cisco' => 'rancid',
'cisco-nx' => 'nxrancid',
'cisco-xr' => 'xrrancid',
'css' => 'cssrancid',
'enterasys' => 'rivrancid',
'erx' => 'jerancid',
'extreme' => 'xrancid',
'ezt3' => 'erancid',
'f5' => 'f5rancid',
'force10' => 'f10rancid',
'fortigate' => 'fnrancid',
'foundry' => 'francid',
'hitachi' => 'htrancid',
'hp' => 'hrancid',
'juniper' => 'jrancid',
'mikrotik' => 'mtrancid',
'mrtd' => 'mrancid',
'mrv' => 'mrvrancid',
'netopia' => 'trancid',
'netscaler' => 'nsrancid',
'netscreen' => 'nrancid',
'procket' => 'prancid',
'redback' => 'rrancid',
'riverstone' => 'rivrancid',
'smc' => 'srancid',
'tnt' => 'tntrancid',
'zebra' => 'zrancid',
'mikrotik' => 'mtrancid'
);
 
DynStatic
Frequent Visitor
Frequent Visitor
Posts: 92
Joined: Thu Feb 18, 2010 3:11 am

Re: RANCID Config Backup

Fri Dec 02, 2011 6:11 am

I am getting the same issue. It seems to be an addition or subtraction of a space. Exactly what pnep posted above.

Going to necro this thread back to life,

I've gotten rancid running and pulling back from a 4.16 route but the diff's seems to show alot more than whats just changed
  /interface wireless manual-tx-power-table
- set Edge comment="" manual-tx-powers="1Mbps:17,2Mbps:17,5.5Mbps:17,11Mbps:17,6Mbps:17,9Mbps:17,12Mbps:17,18Mbps:17,24Mbps:17,36Mbps:17,48Mbps:17,54Mbps: 17,HT20-0:0,HT20-1:0,HT20-2:0,HT20-3:0,HT20-4:0,HT20-5:0,HT20-6:0,HT20-7:0 ,HT40-0:0,HT40-1:0,HT40-2:0,HT40-3:0,HT40-4:0,HT40-5:0,HT40-6:0,HT40-7:0"
+ set Edge comment="" 
+ manual-tx-powers=1Mbps:17,2Mbps:17,5.5Mbps:17,11Mbps:17,6Mbps:17,9Mbps
+ :17,12Mbps:17,18Mbps:17,24Mbps:17,36Mbps:17,48Mbps:17,54Mbps:17,HT20-0
+ :0,HT20-1:0,HT20-2:0,HT20-3:0,HT20-4:0,HT20-5:0,HT20-6:0,HT20-7:0,HT40
+ -0:0,HT40-1:0,HT40-2:0,HT40-3:0,HT40-4:0,HT40-5:0,HT40-6:0,HT40-7:0
It seems to be splitting up some commands at random across lines thus causing a diff, Anyone got any ideas on this?
 
DynStatic
Frequent Visitor
Frequent Visitor
Posts: 92
Joined: Thu Feb 18, 2010 3:11 am

Re: RANCID Config Backup

Fri Dec 02, 2011 6:18 am

This goes in mtrancid. After some testing, it doesn't really fix the issue.
how about
# RouterOS splits long lines with backslashes - this joins them back up
if (/\\\n$/) {
s/\\\n$//;
$buffer .= $_;
if (!/=$/ && !/="[^"]+$/ ) {
$buffer .= "";
}
}
 
timoid
newbie
Posts: 39
Joined: Tue Jan 01, 2008 8:20 am

Re: RANCID Config Backup

Tue Dec 16, 2014 11:25 pm

your line splitting is due to your shell environment supplying a terminal width.

if you run via cron (as an example), it shouldn't define a tty column count and as such shouldn't wrap.

if you run interactively, your shell will have some column count defined, and the mikrotik shell will wrap to suit.

this will make the lines different and hence diff will spit out changes.

it would be nice for an export no-wrap command for backup purposes :)
 
kpenland
just joined
Posts: 19
Joined: Wed Jun 02, 2004 6:04 am
Location: Michigan

Re: RANCID Config Backup

Tue Jul 07, 2015 5:39 pm

I have recently installed Rancid 3.2 and have been successful at getting it configured to run against Mikrotik routers. I am processing about 55 routers of varying versions of RouterOS, mostly 5.x and 6.x . The problem I am having, and it is repeatable, is when running the export command the output of the /port section is extremely unreliable, resulting in many different versions. When examining these diffs, I find the following:
revision 1.174 by rancid, Mon Jul 6 19:39:17 2015 UTC revision 1.175 by rancid, Mon Jul 6 20:11:36 2015 UTC
180 /port /port
181 set 0 name=serial0 set 0 baud-rate=115200 name=serial0
182 set 1 name=serial1 set 1 baud-rate=115200 name=serial1

or no port section at all
revision 1.18 by rancid, Thu Jun 25 20:36:10 2015 UTC revision 1.19 by rancid, Thu Jun 25 21:06:15 2015
/port
set 0 name=serial0
set 1 name=serial1


This is extremely frustrating, and can be reproduced in the terminal window in winbox.
Open a terminal window and run /export a few times and examine the output.
When I find no output after the port section, I try to change the baud rate in winbox-System-Ports but when clicking Apply or Ok, I get an error dialog informing me the change cannot be applied because a background process is using the port. ??huh??
This happens across all versions of RouterOS 6. This does not seem to happen in version 5.x
I have already corrected router configs for the ovpn server mac, and the script line breaks in 5.x, if I can find a fix for the missing port section, Rancid will be very useful for tracking intentional changes in router configs.
It is about useless now as the number of changes to view for a days worth of collecting configs every half hour is overwhelming.
Somebody out there must have run into this, care to share?
 
kpenland
just joined
Posts: 19
Joined: Wed Jun 02, 2004 6:04 am
Location: Michigan

Re: RANCID Config Backup

Tue Jul 07, 2015 10:28 pm

Replying to my last post here, the fix seems to be posted here
http://forum.mikrotik.com/viewtopic.php ... id#p403656

Who is online

Users browsing this forum: roe1974 and 115 guests