I'm curious and I want to know all different methods for getting the IP address from a Linux box, I know ifconfig works well, but wondering if there are any other methods to use to obtain the ip address?
Asked
Active
Viewed 515 times
6 Answers
4
To find the external IP of a box (behind a NAT firewall for instance) try this one-liner:
curl icanhazip.com
So useful and so quick!
Coops
- 6,214
3
The ip tool is quite handy and can give you a bunch of methods for IP address determination and much more.
Quick exmaples:
ip addr show dev wlan0
ip route list | grep -w src | awk '{print "device:",$3, "address:",$9}'
PrecariousJimi
- 1,612
2
I've used
hostname -i
But honestly I shouldn't because this relies on the /etc/hosts file of the machine and not the actual IP address.
Dennis Williamson
- 64,083
Dave Drager
- 8,455
0
The following command will list all IP addresses
ip addr show
The output from ifconfig does not always show secondary addresses on interfaces which do not have a named alias, such as those added by "ip addr add"
MarkR
- 2,928
