Skip to content

Instantly share code, notes, and snippets.

@jvaubourg
jvaubourg / 95th_percentile.sh
Last active Apr 17, 2020
Dirty but simplest way to get a 95th percentile usage on a network interface
View 95th_percentile.sh
#!/bin/bash
netdev=eth0
storage=/tmp/95th_percentile_db
:> $storage
while true; do
rx_bytes_count1=$(awk "/${netdev}/ { print \$2 }" /proc/net/dev)
tx_bytes_count1=$(awk "/${netdev}/ { print \$10 }" /proc/net/dev)
@jvaubourg
jvaubourg / sshvpn.sh
Last active Dec 14, 2019
Access to a remote private IPv4 network, using SSH as a VPN
View sshvpn.sh
#!/bin/bash
# Goal to reach:
# +--------------------------------+ +-----------------------------+
# | LOCAL LAPTOP | In | REMOTE SERVER |
# | tun1 | <=(ter)=> | tun1 |
# | Private IPv4 of the remote net | net | Remote IPv4 private network |
# +--------------------------------+ +-----------------------------+
# Good doc: https://help.ubuntu.com/community/SSH_VPN
@jvaubourg
jvaubourg / ipodns.sh
Last active May 24, 2018
Transparently tunnel any TCP connection (system wide) over SOCKS5/SSH over DNS
View ipodns.sh
#!/bin/bash
set -e
# This is client side, with:
# apt install iodine redsocks
# systemctl disable redsocks
#
# For the server side:
# apt install iodine
@jvaubourg
jvaubourg / shareterminal.sh
Last active Sep 2, 2020
Share a read-only tmux session over HTTPS with password
View shareterminal.sh
#!/bin/bash
# SERVER:
# sudo apt-get install certbot socat tmux
# sudo ./shareterminal.sh
# Your stage: tmux new-session -As remote
# Your spectators: tmux lsc -t remote
#
# CLIENTS:
# curl -N https://tmux.example.com:1337
@jvaubourg
jvaubourg / sharewifi.sh
Created Feb 4, 2017
Share your wifi Internet connection to a device connected with a cable to your laptop (NAT-PT IPv4)
View sharewifi.sh
#!/bin/bash
# +----------------------------+
# Internet_v4 <=> | WIFI <-(sharewifi)-> WIRED | <=> Device
# +----------------------------+
# executed as root
# dnsmasq not running
# $IF_WIRED not handled by an intrusive network manager
# ^C to quit