Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@jvaubourg
jvaubourg / 95th_percentile.sh
Last active April 17, 2020 21:53
Dirty but simplest way to get a 95th percentile usage on a network interface
#!/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 October 28, 2022 19:32
Access to a remote private IPv4 network, using SSH as a VPN
#!/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 17:31
Transparently tunnel any TCP connection (system wide) over SOCKS5/SSH over DNS
#!/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 September 2, 2020 16:21
Share a read-only tmux session over HTTPS with password
#!/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 February 4, 2017 16:47
Share your wifi Internet connection to a device connected with a cable to your laptop (NAT-PT IPv4)
#!/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