Cheatsheet
Display routing table
-
ip r[oute]or
-
route -nor
-
routel
HTTP/2 support check
-
curl -I --http2 <URL>If the site does support
HTTP/2, you will seeHTTP/2 200in the header instead ofHTTP/1.1 200.
Cheatsheet - Windows
Packet Monitor (pktmon)
pktmon is a modern built-in packet capture tool, and it doesn't need any installation or setup, and therefore is the latest and preferred packet capture tool in Windows.
pktmon - Show current status
pktmon statuspktmon - List all filters
pktmon filter listpktmon - Add a filter for TCP
- If we have multiple rules, the individual filter lines will be treated as
ORstatements. - For the individual components to be treated as
ANDstatements, they need to be entered on the same filter line.
pktmon filter add $filter_name -t $protocol -p $portpktmon - Lists all active networking components that can be monitored
pktmon list -apktmon - Start packet capture
pktmon start -c -f $etl_filepktmon - Convert ETL to PCAPNG
pktmon etl2pcap $ETL_FILE -o $PCAPNG_FILETCP/IP (opens in a new tab)
Application Layer
HTTP
HTTP - CONNECT
Internet Layer
IP
-
IP addressing methods
-
Unicast
Single unique node in the network
-
Broadcast
All nodes in the network
-
Multicast
-
Anycast
-
-
Resources
Get public IP address
curl ifconfig.co
Subnet
-
CIDRnotation is equivalent to Subnet mask10.0.1.1/24216.202.192.66/22These are equivalent to
IP address:
10.0.1.1with subnet mask of255.255.255.0IP address:
216.202.196.66with a subnet mask example of255.255.252.0 -
RFC 1878 - Variable Length Subnet Table For IPv4 (opens in a new tab)
Routing
-
Resources
Transport Layer
TCP
TCP - PROXY
- The PROXY protocol - Versions 1 & 2 (opens in a new tab)
- Accepting the PROXY Protocol | NGINX Documentation (opens in a new tab)
TCP - Cheatsheet
TCP - Cheatsheet - Send a raw TCP packet
-
Java
Doesn't support natively, need JNI, e.g GitHub - jpcap/jpcap (opens in a new tab)
-
Python
TCP - Cheatsheet - Packet capture on Windows
pktmon is a modern built-in packet capture tool and should be preferred.
-
Start capture
-
Option 1: Using Network shell (netsh)
netsh trace start capture=yes tracefile=C:\Temp\NetTraces\capture.etl persistent=yes maxsize=4096 -
Option 2: Using Packet Monitor (pktmon)
pktmon filter add $filter_name -t $protocol -p $portpktmon start -c -f $ETL_FILE
-
-
Stop capture
-
Option 1: Using Network shell (netsh)
netsh trace stop -
Option 2: Using Packet Monitor (pktmon)
pktmon stop
-
-
Convert
ETLtoPCAPNG-
Option 1: Use
etl2pcapngInstall
etl2pcapngfrom GitHub - microsoft/etl2pcapng (opens in a new tab)scoop install main/etl2pcapngetl2pcapng $ETL_FILE $PCAPNG_FILE -
Option 2: Use
pktmonto convertETLtoPCAPNGpktmon etl2pcap PktMon.etl -o PktMon.pcapng
-
-
Open
PCAPNGinWireshark
TCP - Implementation
Network troubleshooting
-
There are many tools available but focus on the following ones:
-
traceroute: works with TCP and UDP too -
lsof -
ss -
ncat: modern Netcat replacement
-
-
Connection refused
-
Connection refusedmeans that the port you are trying to connect to is not actually open. -
Connection refusedis usually due to one of the following reasons:-
The port is not open on the destination host.
-
A firewall is blocking the connection on the host or an intermediate network device.
-
The port is not open on the source host.
-
The source host's firewall is blocking the connection.
-
-
Applications
Chromium-based browsers
chrome://net-internals
Networks tools
chrome://net-export
Capture net logs
-
Resources
- Chrome Platform Status (opens in a new tab)
- The Chromium Projects - Design Documents - Network stack (opens in a new tab)
- The Performance of Open Source Software - High Performance Networking in Chrome (opens in a new tab)
- A Crash Course in Debugging with chrome://net-internals (opens in a new tab)
- Life of a URLRequest (opens in a new tab)
- Network Service (opens in a new tab)
Firefox
Cheatsheet - Firefox
Honour system host file (/etc/hosts)
about:config
# Set to false
network.dns.offline-local = falseLinux
iptables
Debian-based distributionssuch asUbuntucan use a front-end program calledUncomplicated FireWall (ufw)for managing theiptables/Netfilterfirewall stack. As its name implies,ufwis designed to make managingiptablesrules easy (that is, uncomplicated).
Verifying the iptables Kernel Module is loaded
lsmod | grep ip_tablesWindows
Check Open TCP/IP Ports in Windows
Exclude a port occupied by Hyper-V
dism.exe /Online /Disable-Feature:Microsoft-Hyper-V
# Enable the target port
netsh int ipv4 add excludedportrange protocol=tcp startport=<PORT> numberofports=1
dism.exe /Online /Enable-Feature:Microsoft-Hyper-V /AllCheck System Proxy Settings
netsh winhttp show proxy(Does not work for PAC script)- In Google Chrome: chrome://net-internals/#proxy
- In the case of PAC (opens in a new tab), download the script via the link specified in system proxy config, and find the proxy address and port in the script code. The script is written in JavaScript.
WSL - Networking with host
-
Determine IP of Windows for access from
WSLIn
Windows-
ipconfig-
Ethernet adapter vEthernet (WSL)IPv4 Address
-
-
-
Determine IP of
WSLfor access from Windows# In WSL ip addr show eth0# In Windows wsl hostname -I -
Resources
Library
Socket abstraction, broker-less
-
Modern option
-
Predecessor of
NNG -
Predecessor of
nanomsg
IPC
UNIX Domain Socket
-
Favour
UNIX Domain SocketoverTCP/IPfor local communication-
UNIX Domain Socketis faster thanTCP/IPloopback -
UNIX Domain Socketis more secure thanTCP/IPloopback- Transit entirely through the kernel, no evesdropping
- File system access control
-