Skip to content

Instantly share code, notes, and snippets.

{
:do {
:local debug 1;
:local flagInterface "";
:local srcInterface "";
:local srcAddress "";
:set srcInterface "###INTERFACE_NAME###";
:set flagInterface "###FLAG_INTERFACE_NAME###";
@elico
elico / RouterOS-Detect-internet-connection.rsc
Last active April 10, 2024 22:09
A demo script to detect by url if a specific interface is up.
{
:do {
:local srcInterface1 "ether1-WAN1";
:local srcInterface2 "ether2-WAN2";
:local srcInterface3 "ether3-LTE";
:local srcInterface4 "pppoe-WAN1";
:local srcInterface5 "pppoe-WAN2";
:local srcInterface6 "pppoe-LTE1";
:local flagInterface "";
@elico
elico / Dockerfile
Created March 20, 2017 10:02
ipfire build docker testing
FROM ubuntu:16.04
ARG DEBIAN_FRONTEND=noninteractive
RUN apt-get update \
&& apt-get upgrade -y \
&& apt-get install -y linux-headers-generic \
&& apt-get install -y build-essential git-core g++ realpath patch byacc make python-urlgrabber autoconf automake nano wget pv dialog
RUN mkdir /build && chmod +x /build
@elico
elico / backup-by-email.rsc
Last active March 26, 2024 21:50
RouterOS v7 hardware appliance email backup script
{
:do {
:log info "STARTING BACKUP process";
:local customerNumber "Ac3_Cust.no_1";
:local boardSerial [/system/routerboard/get serial-number];
:local sendMail true;
:local uploadFile false;
:local mailServer "smtp.gmail.com";
/interface/veth/add address=172.21.0.201/24 gateway=172.21.0.254 name=veth201
/interface/bridge/port/add bridge=dockers interface=veth201
/container/envs/add name=adguard_envs key=TZ value="Asia/Jerusalem"
/container/config/set registry-url=https://registry-1.docker.io tmpdir=usb1-part1/pull
/container/mounts/add dst=/opt/adguardhome/conf name=adguardhome_conf src=usb1-part1/adguardhome/conf
/container/mounts/add dst=/opt/adguardhome/work name=adguardhome_work src=usb1-part1/adguardhome/work
/container/add remote-image=adguard/adguardhome:latest interface=veth201 logging=yes mounts=adguardhome_conf,adguardhome_work root-dir=usb1-part1/adguardhome/root envlist=adguard_envs start-on-boot=yes
:local endpoint www.example.com;
:local wireguardInterface wireguard3;
:local wireguardInterfacePort [/interface/wireguard/get $wireguardInterface listen-port];
:foreach i in=[/interface/wireguard/peers/find where disabled=no endpoint-address=$endpoint] do={
:local LastHandshake [/interface/wireguard/peers/get $i last-handshake];
:if (([:tostr $LastHandshake] = "") or ($LastHandshake > [:totime "5m"])) do={
/interface/wireguard/set 0 listen-port=$wireguardInterfacePort name=$wireguardInterface;
:log warning "fixed wireguard";
@elico
elico / ufdbguard.conf
Created February 12, 2024 10:55
Example ufdbguard
logdir "/var/ufdbguard/logs"
dbhome "/var/ufdbguard/blacklists"
administrator "<a href=mailto:ngtech1ltd@gmail.com> the support desk </a>"
port 3977
interface "all" # only used for TCP sockets
logblock off
@elico
elico / nftables-lb-wan.sh
Created August 25, 2020 03:07
Dual WAN Flow Base PCC nftables load balancing example script
#!/usr/bin/env bash
DEST_NET="192.168.111.0/24"
NEXT_HOPS="2"
NEXT_HOP_1="192.168.126.202"
NEXT_HOP_2="192.168.126.203"
NEXT_HOP_1_TABLE="202"
@elico
elico / .env
Created June 18, 2023 21:01
Helper script for RouterOS GeoIP managment
USERNAME="admin"
PASSWORD="testAdmin"
@elico
elico / activate-datacenter-2019-vm.ps1
Created November 29, 2023 09:44
Convert Windows Server Evaluation to vm license
# https://learn.microsoft.com/en-us/windows-server/get-started/automatic-vm-activation#avma-keys
# https://stefanos.cloud/kb/how-to-convert-and-activate-windows-server-evaluation-with-purchased-license-keys/
# DISM /online /Get-TargetEditions
DISM /online /Set-edition:ServerDatacenter /ProductKey:H3RNG-8C32Q-Q8FRX-6TDXV-WMBMW /AcceptEula