-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
10 changed files
with
411 additions
and
7 deletions.
There are no files selected for viewing
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
# Mikrotik One Liners | ||
|
||
|
||
## Mikrotik One-Liners | ||
|
||
### return average ping time of a domain name: | ||
|
||
:put ([/tool flood-ping [:resolve "www.mikrotik.com"] count=3 as-value]->"avg-rtt") | ||
|
||
### return average ping time of a ip: | ||
|
||
:put ([/tool flood-ping 1.1.1.1 count=3 as-value]->"avg-rtt") | ||
|
||
|
||
|
||
### set best dns servers based of average ping time: | ||
|
||
:global ping2 ([/tool flood-ping 8.8.8.8 count=3 as-value]->"avg-rtt");:global ping1 ([/tool flood-ping 1.1.1.1 count=3 as-value]->"avg-rtt");:if ($ping1>$ping2) do={[/ip dns set servers=1.1.1.1]} else={[/ip dns set servers=8.8.8.8]}; | ||
|
||
|
||
### adding the script to the scripts section on mikrotik: | ||
|
||
/system script add name=best_DNS source=[:global ping2 ([/tool flood-ping 8.8.8.8 count=3 as-value]->"avg-rtt");:global ping1 ([/tool flood-ping 1.1.1.1 count=3 as-value]->"avg-rtt");:if ($ping1>$ping2) do={[/ip dns set servers=1.1.1.1]} else={[/ip dns set servers=8.8.8.8]};]; | ||
|
||
### run that script with scheduler: | ||
|
||
system scheduler add name=sch-dns interval=60s on-event=s1 | ||
|
||
|
||
### run that script with cli: | ||
|
||
system scripts run s1 | ||
|
||
|
||
### Delete logs by terminal: | ||
|
||
one line | ||
|
||
/system logging action set memory memory-lines=1 | ||
|
||
or one hundred lines | ||
|
||
/system logging action set memory memory-lines=100 | ||
|
||
|
||
|
||
|
||
|
||
### redirect a.b.c.d (ip) to 192.168.1.101:5900 | ||
|
||
/ip firewall nat add chain=dstnat dst-address=a.b.c.d protocol=tcp dst-port=5900 | ||
action=dst-nat to-addresses=192.168.1.101 to-ports=5900 | ||
|
||
|
||
|
||
### redirect a request to another port (port 52 redirects to 22) | ||
|
||
ip firewall nat add chain=dstnat protocol=tcp dst-port=52 action=redirect to port=22 | ||
|
||
|
||
|
||
|
||
### Drop google.com with just a line | ||
|
||
/ip firewall filter | ||
add action=drop chain=forward content=google.com | ||
|
||
### fetch Iranian IP Address | ||
you can change it to any country you want | ||
|
||
/tool fetch url=http://www.iwik.org/ipcountry/mikrotik/IR | ||
/import file-name=IR | ||
|
||
|
||
|
||
|
||
### redirect DNS request to a IP | ||
|
||
/ip dns static add regexp=".*\\.com\$" forward-to=192.168.1.186 | ||
|
||
|
||
|
||
### check for updates just with one script | ||
|
||
after 6.31 version: | ||
|
||
/system package update | ||
Check-for-updates once | ||
: delay 1s; | ||
: If ([get status] = "New version is available") do= {install} | ||
|
||
|
||
before 6.31 version: | ||
|
||
System package update | ||
Check-for-updates | ||
: delay 1s; | ||
: if ( [get current-version] != [get latest-version]) do={ upgrade } | ||
|
||
|
||
### save backup and restore backup | ||
|
||
|
||
save Configuration | ||
|
||
/system backup save filename=[backup_filename.backup] | ||
|
||
Load Configuration | ||
|
||
/system backup load filename=[backup_filename.backup] | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,10 @@ | ||
# Security Policy | ||
|
||
|
||
|
||
## CopyRight Violations | ||
If there are any copyright violations by me pleaese inform me! | ||
|
||
## Reporting a Vulnerability | ||
|
||
If you discover a security vulnerability in our project, please report it to us by emailing [email protected]. Please do not disclose the vulnerability publicly until we have had a chance to address it. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
/ip firewall filter | ||
add action=add-src-to-address-list address-list=bruteforce_blacklist address-list-timeout=1d chain=input comment=Blacklist connection-state=new dst-port=22 protocol=tcp src-address-list=connection3 | ||
add action=add-src-to-address-list address-list=connection3 address-list-timeout=1h chain=input comment="Third attempt" connection-state=new dst-port=22 protocol=tcp src-address-list=connection2,!secured | ||
add action=add-src-to-address-list address-list=connection2 address-list-timeout=15m chain=input comment="Second attempt" connection-state=new dst-port=22 protocol=tcp src-address-list=connection1 | ||
add action=add-src-to-address-list address-list=connection1 address-list-timeout=5m chain=input comment="First attempt" connection-state=new dst-port=22 protocol=tcp | ||
add action=accept chain=input dst-port=22 protocol=tcp src-address-list=!bruteforce_blacklist |
Oops, something went wrong.