Skip to content

Instantly share code, notes, and snippets.

Sometimes you want to retrieve EC2 insntances' region information.

You can query that information through instance metadata(169.254.169.254).

$ curl --silent http://169.254.169.254/latest/dynamic/instance-identity/document
{
  "privateIp" : "172.31.2.15",
  "instanceId" : "i-12341ee8",
  "billingProducts" : null,
 "instanceType" : "t2.small",
@madmouser1
madmouser1 / wireguard.conf
Created February 15, 2021 21:40 — forked from nealfennimore/wireguard.conf
Wireguard VPN - Forward all traffic to server
# ------------------------------------------------
# Config files are located in /etc/wireguard/wg0
# ------------------------------------------------
# ---------- Server Config ----------
[Interface]
Address = 10.10.0.1/24 # IPV4 CIDR
Address = fd86:ea04:1111::1/64 # IPV6 CIDR
PostUp = iptables -A FORWARD -i wg0 -j ACCEPT; iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE; ip6tables -A FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -A POSTROUTING -o eth0 -j MASQUERADE # Add forwarding when VPN is started
PostDown = iptables -D FORWARD -i wg0 -j ACCEPT; iptables -t nat -D POSTROUTING -o eth0 -j MASQUERADE; ip6tables -D FORWARD -i wg0 -j ACCEPT; ip6tables -t nat -D POSTROUTING -o eth0 -j MASQUERADE # Remove forwarding when VPN is shutdown
@madmouser1
madmouser1 / ssh_tunneling.md
Created January 26, 2021 22:30 — forked from ashrithr/ssh_tunneling.md
ssh tunneling and port forwarding

###Single hop tunelling:

ssh -f -N -L 9906:127.0.0.1:3306 [email protected]

where,

  • -f puts ssh in background
  • -N makes it not execute a remote command
@madmouser1
madmouser1 / install
Created March 15, 2020 12:43 — forked from tpaivaa/install
OPENSIPS 3.0 OPENSIPS CP 8.3.0 on Debian 10 Buster
Should be installed in this order :)
### Prerequisites
apt install gnupg
### MariaDB
apt-key adv --recv-keys --keyserver keyserver.ubuntu.com 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.liquidtelecom.com/repo/10.4/debian buster main'
@madmouser1
madmouser1 / cross-cables.py
Created September 29, 2019 20:07 — forked from candlerb/cross-cables.py
Netbox report to highlight cables between sites and cables between racks (apart from rearport to rearport)
from extras.reports import Report
from dcim.models import Cable, RearPort
from dcim.constants import *
from circuits.models import CircuitTermination
CABLE_TYPES_OK_BETWEEN_RACKS = {
CABLE_TYPE_DAC_PASSIVE,
}
class CheckCableLocality(Report):
@madmouser1
madmouser1 / Install-Cypher-Syntax-Highlight-ST3.md
Created July 12, 2019 15:18 — forked from flekschas/Install-Cypher-Syntax-Highlight-ST3.md
Add Syntax Highlighting for Cypher in Sublime Text 3

Credit goes to

  1. Jan Klaas Kollhof (and Fred Benenson)
  2. Chris Skardon

Installation

Since the original plugin has been developed for Sublime Text 2 we have to install it manually.

  1. Go to https://github.com/fredbenenson/sublime-cypher, download ZIP of the repo, extract the content and rename the folder to ‘Cypher’. You can download the original repo from https://github.com/kollhof/sublime-cypher but Fred Benenson introduced a handy fix for UTF-8 data, which hasn't integrated at the point of this writing.
@madmouser1
madmouser1 / reset_routing_table.sh
Created April 4, 2018 07:11 — forked from midwire/reset_routing_table.sh
Reset routing table on OSX
#!/usr/bin/env bash
# Reset routing table on OSX
# display current routing table
echo "********** BEFORE ****************************************"
netstat -r
echo "**********************************************************"
for i in {0..4}; do
sudo route -n flush # several times
@madmouser1
madmouser1 / echo with timestamp
Created October 17, 2017 10:18
Echo with timestamp
echo "foo.bar 1 `date +%s`" | nc localhost 2003
@madmouser1
madmouser1 / ROS_L7_BT_Matcher
Created July 6, 2017 16:22
RouterOS L7 bittorrent matcher
^(\x13bittorrent protocol|azver\x01$|get /scrape\?info_hash=get /announce\?info_hash=|get /client/bitcomet/|GET /data\?fid=)|d1:ad2:id20:|\x08'7P\)[RP]
#directory: /media/music/sorted
directory: /media/nas2/UnsortedMusic/reworked/
library: ~/beets/unsortedmusiclibrary.blb
pluginpath:
- /home/username/beetsplug/
plugins: madmousetempo the replaygain discogs inline lastgenre duplicates scrub info random mbsync fromfilename lyrics
# chroma