Skip to content

Instantly share code, notes, and snippets.

@tcpdump-examples
Last active December 23, 2022 08:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tcpdump-examples/42d2caf239123dbd3a4cadb69dbeb999 to your computer and use it in GitHub Desktop.
Save tcpdump-examples/42d2caf239123dbd3a4cadb69dbeb999 to your computer and use it in GitHub Desktop.

Reference: 3 Easy Ways to Find IP address in Linux

Find private ip address for all network interfaces in Linux

ip a
ip addr
ip address show 
ifconfig -a

Check private ip address for specific network interface in Linux

ip addr show dev eth1
ifconfig eth1

Check private ip address in bash script

ip -4 -o a | cut -d ' ' -f 2,7 | cut -d '/' -f 1
ip -4 addr show eth0 | grep -oP "(?<=inet ).*(?=/)"
ip addr show eth0 | grep inet | awk '{ print $2; }' | sed 's/\/.*$//'

Check public ip address in Linux

curl ifconfig.me/all
dig +short myip.opendns.com @resolver1.opendns.com
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment