The following command allows Winbox from the 192.168.0.0/16, and 10.0.10.0/24 network ranges. You can change winbox to ssh or any of the other services in ip services.
ip service set address="192.168.0.0/16, 10.0.10.0/24" winbox
The following command allows Winbox from the 192.168.0.0/16, and 10.0.10.0/24 network ranges. You can change winbox to ssh or any of the other services in ip services.
ip service set address="192.168.0.0/16, 10.0.10.0/24" winbox
Copy and paste the following into a file named mtbypass.sh and then “chmod +x mtbypass.sh” Or download from this direct link. Be sure to change the username and password
#!bin/bash filelist="bypasslist.txt" username="admin" password="password!" ip="$1" for i in `cat ${filelist}` do address=`echo $i | cut -d= -f1` mac=`echo $i | cut -d= -f2` sshpass -p ${password} ssh ${username}@${ip} "ip hotspot ip-binding add address=${address} mac-address=${mac} type=bypassed" done
Now create a file named bypasslist.txt and put all the addresses you want bypassed. You’ll need the Mac Address and the IP Address.
Example file
192.168.88.2=4C:5E:0C:B8:4E:01 192.168.88.3=3E:AA:A1:2D:8B:2C 192.168.88.5=DE:D1:39:65:91:4E
Usage of script is
./mtbypass.sh MikrotikIP
Example:
./mtbypass.sh 192.168.88.1
ssh: connect to host 192.168.1.158 port 22: Connection refused
Wrong SSH port. Check /etc/ssh/sshd_config on linux, or in RouterOS IP->services->SSH
ssh_exchange_identification: Connection closed by remote host
Check the hosts.allow and hosts.deny files. If your getting this error connecting to a Mikrotik check the IP services and the “Available From” addresses.
This is a Linux script for creating and backing up backups on Mikroitk routers.
Features
Future Features
These are features I am planning on adding to the script in the future
Current Bugs or limitations
Requirements
Installing
Download program
wget www.incredigeek.com/home/downloads/mtbackup/mtbackup.sh
chmod +x mtbackup.sh
Now open up the script and edit the variables at the top for your username, password, and where you want the backups.
nano mtbackup.sh
When you have finished editing the variables, hit CTRL+x, and then “y” and then “enter” to save the file.
If you want to setup the script to backup on a regular basis then setup the script to run in cron.
Run “crontab -e” and add the following line
10 1 * * 1 cd /root/mtbackup-1.0/ & sh mtbackup -b
Hit CTRL+x, and then “y” and then “enter” to save the file.
Adding routers to backup
Adding routers is really easy. All you have to do is run the script with the -a option and then the ip address and the script will check if it can reach the IP and then add it to the IP Database i.e.(ip.lst file that contains all the routers ip addresses)
./mtbackup.sh -a 192.168.88.1
Example:
[root@localhost mtbackup-1.0]# ./mtbackup.sh -a 192.168.88.1 ################################################################# This is a Mikrotik Backup Utility. Still being updated and worked on!!! ################################################################# Adding 192.168.88.1 to the ip DB Added 192.168.88.1 to ipDB [root@localhost mtbackup-1.0]#
You can manually backup all the routers by running the script with just the “-b” option. It’ll read every IP in the IP database and create a backup for each one and put it in the backup folder with is normally “./backups”, you can change it in the variables portion of the script.
./mtbackup.sh -b
List routers in the IP Database
[root@localhost mtbackup-1.0]# ./mtbackup.sh -L ################################################################# This is a Mikrotik Backup Utility. Still being updated and worked on!!! ################################################################# Listing Hosts... 192.168.88.1 10.200.1.1 172.20.1.1 33.11.2.22 [root@localhost mtbackup-1.0]#
Backup Single router
[root@localhost mtbackup-1.0]# ./mtbackup.sh -B 192.168.88.1 ################################################################# This is the Mikrotik Backup Utility. Currently under construction!!! ################################################################# Starting to do backup on 10.9.0.1 Configuration backup saved [root@localhost mtbackup-1.0]#
Other commands
[root@localhost mtbackup-1.0]# ./mtbackup.sh -h ################################################################# This is the Mikrotik Backup Utility. Still being updated and worked on!!! ################################################################# Usage ./mtbackup.sh [OPTIONS] ./mtbackup.sh -b 192.168.88.1 -l List backups -L List Hosts -b Backup all hosts in the IP database -B {ip} Backup Single Host, Specife IP -a {ip} Add ip to IP database -v Version [root@localhost mtbackup-1.0]#