Skip to content

Instantly share code, notes, and snippets.

#!/usr/bin/env sh
apk update
apk add openvswitch openvswitch-bash-completion bash bash-completion openvswitch-doc openvswitch-openrc vim tcpdump ruby ruby-rdoc git
sed -i -e "s@mouse\=a@mouse=r@g" /usr/share/vim/vim*/defaults.vim
grep "mouse=a" /usr/share/vim/vim*/defaults.vim
grep "auto switch0" /etc/network/interfaces >/dev/null
RES="$?"
@elico
elico / email-backup.rsc.j2
Created June 14, 2024 13:35
a simple backup script for RouterOS V7.x
{
:do {
:log info "STARTING BACKUP";
:global customerIdentificationVar;
:local customerIdentification "{{ customer_identifictation }}";
if ( [:len $customerIdentificationVar] > 0 ) do={
:set customerIdentification "$customerIdentificationVar";
@elico
elico / send-backup-to-server.rsc
Created June 10, 2024 23:02
Send a rsc backup to a server over a POST request.
{
/export show-sensitive file=routeros-generic-config.rsc;
:local deviceSerialNumber "1234";
:local apiUsername "$deviceSerialNumber";
:local apiPassword "secretPassword";
:lcal backupServerDomain "cep-backup.ngtech.home"
:local fileContent [/file get routeros-generic-config.rsc contents];
:local apiUrl "https://$backupServerDomain/api/v1/backup/$apiUsename/generic";
:local postData "$fileContent";
:local contentLength [:len $fileContent];
@elico
elico / Prefer-Wifi-Connections.ps1
Last active December 1, 2025 19:48
Powershell Scripts to change the interfaces preference to WIFI and another to reset which will probably prefer the ethernet
# Get the network interfaces
$interfaces = Get-NetIPInterface | Where-Object {$_.InterfaceAlias -match "Wi-Fi" -or $_.InterfaceAlias -match "vEthernet" -or $_.InterfaceAlias -match "Ethernet"}
# Set a higher metric value for the Ethernet interface
foreach ($interface in $interfaces) {
Write-Host $interface.InterfaceAlias
if ($interface.InterfaceAlias -match "Ethernet") {
Write-Host "Ethernet Interface"
Set-NetIPInterface -InterfaceAlias $interface.InterfaceAlias -InterfaceMetric 100
@elico
elico / set-mgmnt-dhcp-client.ps1
Created June 5, 2024 20:56
Set a static address on a specific interface with specific ip string prefix
# Variables
$ipStringPrefix = "192.20.20." # Replace with the desired IP address prefix
$newIpAddress = "192.20.20.150" # Replace with the desired new static IP address
$newPrefixLength = 24 # Replace with the desired subnet mask length
# Find the interface by CIDR
$interfaces = Get-NetIPAddress | Where-Object {
$_.IPAddress.StartsWith($ipStringPrefix)
}
@elico
elico / hap-ac2-7.15-default.rsc
Created June 5, 2024 10:25
Mikrotik RouterOS AC2 7.15 default script
# 1970-01-02 00:02:40 by RouterOS 7.15
# software id = 8A8H-8IIG
#
script: #| Welcome to RouterOS!
#| 1) Set a strong router password in the System > Users menu
#| 2) Upgrade the software in the System > Packages menu
#| 3) Enable firewall on untrusted networks
#| 4) Set your country name to observe wireless regulations
#| -----------------------------------------------------------------------------
#| RouterMode:
@elico
elico / ppp-profile-on-up.rsc
Last active June 1, 2024 21:03
Example of ppp profile on-up script for a pppoe-client interface
{
:do {
:log info ("ppp on-up script for interface id: " . $interface . " Started" );
:local interfaceName [/interface/get $interface name];
:log info ("ppp on-up script for interface name: " . $interfaceName . " Started" );
:local routingTable "WAN1";
:local routingTable "WAN2";
@elico
elico / README.md
Last active June 1, 2024 18:13
Mikrotik RouterOS Lease script example
@elico
elico / filter-chr-rsc-for-import.rb
Created May 30, 2024 23:15
filter-chr-rsc-for-import.rb
#!/usr/bin/env ruby
def filter_text_file(input_file)
# Read the input file content
content = File.read(input_file)
# Split the content into lines
lines = content.split("\n")
# Initialize a variable to track if we are inside a block to remove
{
:do {
:local debug 1;
:local flagInterface "";
:local srcInterface "";
:local srcAddress "";
:set srcInterface "###INTERFACE_NAME###";
:set flagInterface "###FLAG_INTERFACE_NAME###";