Skip to content

Instantly share code, notes, and snippets.

@cetinajero
Last active July 25, 2022 22:52
Show Gist options
  • Save cetinajero/f947e6694be20a03481ccf402c7369f0 to your computer and use it in GitHub Desktop.
Save cetinajero/f947e6694be20a03481ccf402c7369f0 to your computer and use it in GitHub Desktop.
Network tools & list of interface bandwidths

SSH Port Forwarding

SSH Port Forwarding, aka SSH Tunneling.

Local Forwarding

Local forwarding is used to forward a port from the client machine to the server machine. Basically, the SSH client listens for connections on a configured port, and when it receives a connection, it tunnels the connection to an SSH server. The server connects to a configurated destination port, possibly on a different machine than the SSH server.

ssh -L <local-listening-port>:<remote-destination-host>:<remote-destination-port> <ssh-server>

ssh -L 4000:172.31.29.64:8080 asterisk.grupopv.mx

Remote Forwarding

This allows anyone on the remote server to connect to TCP port 8080 on the remote server. The connection will then be tunneled back to the client host, and the client then makes a TCP connection to port 80 on localhost. Any other host name or IP address could be used instead of localhost to specify the host to connect to.

Commonly used for opening backdoors into an enterprise.

ssh -R <remote-listening-port>:<local-destination-host>:<local-destination-port> <ssh-server>

ssh -R 4000:192.168.1.254:80 asterisk.grupopv.mx

Internet speedtest

Using Ookla and Python: github.com/sivel/speedtest-cli

curl -s https://raw.githubusercontent.com/Kerybas/speedtest-cli/master/speedtest.py | python -

Using curl and ash: github.com/cetinajero/curl-speedtest

curl -s https://raw.githubusercontent.com/cetinajero/curl-speedtest/master/speedtest.sh | sh -

Iperf 2

A network traffic tool for measuring TCP and UDP performance with metrics around both throughput and latency.

Options

Option Description
-s Run server
-c server Run client
-u, --udp Use UDP rather than TCP
-b, --bandwidth n[kmgKMG] Set target read rate to n bits/sec. TCP only for the server
-i, --interval n Pause n seconds between periodic bandwidth reports
-t, --time n Time in seconds to listen for new traffic connections, receive traffic or transmit traffic
-p, --port n Set server port to listen on/connect to to n (default 5001)
-d, --dualtest Do a bidirectional test simultaneously

TCP examples

TCP server

iperf -s

TCP client

iperf -c 192.168.1.1 -i1 -t60
iperf -c iperf.he.net -i1 -t60

UDP examples

UDP server

iperf -s -i1 -u

UDP client

iperf -c 192.168.1.1 -i1 -t60 -u -b 1000M
iperf -c iperf.he.net -i1 -t60 -u -b 1000M

Network monitor

MTR combines the functionality of the 'traceroute' and 'ping' programs in a single network diagnostic tool.

MTR with options:

  • IPv4
  • Show IPs
  • CSV
  • Count 500
sudo mtr -4bCc 500 fg.mex.grupopv.mx > mtr.csv

MTR with variables:

TERM=vt220 sudo mtr -4bc 500 fg.mex.grupopv.mx

Enable ICMP on Windows

Run:

netsh advfirewall firewall add rule name="ICMP Allow incoming V4 echo request" protocol=icmpv4:8,any dir=in action=allow

List of interface bandwidths

Technology Nominal (Bits/s) Nominal (Bytes/s) Real Year
Modem 14.4k (V.32) 14.4 kb 1.8 kB 1991
Modem 28.8k (V.34) 28.8 kb 3.6 kB 1994
Modem 56k (V.90) 56.0 kb 7 kB 1998
Bluetooth 1.1 1 Mb 125 kB 2002
CD Controller (1×) 1.171 Mb 146 kB 1988
USB 1.0 1.536 Mb 192 kB 1996
E1 2.048 Mb 256kB
Bluetooth 2.0+EDR 3 Mb 375 kB 2004
Ethernet (10BASE-X) 10 Mb 1.25 MB 1980
IEEE 802.11b 11 Mb 1.375 MB 1999
DVD Controller (1×) 11.1 Mb 1.32 MB 1996
USB 1.1 12 Mb 1.5 MB 1996
Bluetooth 3.0 25 Mb 3.125 MB 2009
Bluetooth 4.0 25 Mb 3.125 MB 2010
Bluetooth 5.0 50 Mb 6.25 MB 2016
IEEE 802.11a 54 Mb 6.75 MB 1999
IEEE 802.11g 54 Mb 6.75 MB 2003
Fast Ethernet (100BASE-X) 100 Mb 12.5 MB 1995
USB 2.0 high speed 480 Mb 60 MB 2000
IEEE 802.11n (aka Wi-Fi 4) 600 Mb 75 MB 2009
Gigabit Ethernet (1000BASE-X) 1 Gb 125 MB 1998
PCI 32-bit/33 MHz 1.067 Gb 133.33 MB 1993
PCI 64-bit/33 MHz 2.133 Gb 266.66 MB 1993
PCI 32-bit/66 MHz 2.133 Gb 266.66 MB 1995
PCI Express 1.0 (×1 link) 2.5 Gb 312.5 MB 2004
2.5 Gigabit Ethernet (2.5GBASE-T) 2.5 Gb 312.5 MB 2016
PCI Express 2.0 (×1 link) 5 Gb 625 MB 2007
PCI Express 1.0 (×2 link) 5 Gb 625 MB 2011
USB 3.0 SuperSpeed (aka USB 3.1 Gen 1) 5 Gb 625 MB 2010
5 Gigabit Ethernet (5GBASE-T) 5 Gb 625 MB 2016
IEEE 802.11ac (aka Wi-Fi 5) 6.93 Gb 866.25 MB 2012
PCI Express 3.0 (×1 link) 8 Gb 984.6 MB 2011
10 Gigabit Ethernet 9.953 Gb 1.244125 GB 2002
USB 3.1 SuperSpeed+ (aka USB 3.1 Gen 2) 10 Gb 1.250 GB 2013
IEEE 802.11ax (aka Wi-Fi 6) 11 Gb 1.375 GB 2019
Thunderbolt 20 Gb 2.5 GB 2011
Thunderbolt 2 20 Gb 2.5 GB 2013
USB 3.2 SuperSpeed+ (aka USB 3.2 Gen 2×2) 20 Gb 2.5 GB 2017
25 Gigabit Ethernet (25GBASE-X) 25 Gb 3.125 GB 2016
Thunderbolt 3 two links 40 Gb 5 GB 2015
USB 4 40 Gb 5 GB 2019
PCI Express 1.0 (×32 link) 80 Gb 8 GB 2011
PCI Express 2.0 (×32 link) 160 Gb 16 GB 2007
PCI Express 3.0 (×32 link) 256 Gb 31.51 GB 2011
PCI Express 4.0 (×16 link) 256 Gb 31.51 GB 2018
PCI Express 5.0 (×16 link) 512 Gb 63.02 GB 2019
#!/bin/bash
test_upstream() {
echo -e "\nRun: \`iperf -s -i 1 -p 4000\` at the server side\n"
iperf -c 172.31.31.64 -i 1 -p 4000 -t 60
}
test_downstream() {
echo -e "\nRun: \`iperf -c 172.31.35.42 -i 1 -p 8080 -t 60\` at the server side\n"
iperf -s -i 1 -p 8080
}
case "$1" in
"-u")
test_upstream
;;
"--up")
test_upstream
;;
"-d")
test_downstream
;;
"--down")
test_downstream
;;
*)
echo "Usage: iperf.sh [--up|--down]"
exit 1
;;
esac
@cetinajero
Copy link
Author

cetinajero commented Mar 23, 2020

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment