Karan Sharma

Ramblings on tech, cycling, and finance

Networking

tcpdump

Check for packets flowing out from an interface for a specific CIDR

sudo tcpdump -v -i wlo1 dst net 192.168.0.0/16

Explanation:

ip

List routing table

ip route

Find which interface and route a particular IP is taking

ip route get 192.168.1.1

ifconfig

Find the primary IP of local machine

Get the IP of all interfaces:

ifconfig | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'

Get the IP of a specific interface:

For eg (wlo1):

ifconfig wlo1 | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'

Source