Karan Sharma

Essential Linux Networking Commands

1 minutes (205 words)

πŸ”—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

Tags: #Linux #Networking