-2

There are so many questions asking basically: how do I get my local IP address? None of answers are portable, they all seem like a hack. This seems like such a common need, but there are no good solutions. Why? Why can't we have a nice Unix tool that simply does this? Is this actually a hard problem?

1
  • 2
    It is not unix-related, it is how network works - you can be behind router on local network, and your computer doesn't know what its outside address is. What you need is just parameters of this local network and all packages from/to your computer are just forwarded by the router.
    – jimmij
    Commented Oct 20, 2018 at 20:39

1 Answer 1

2

Why do you consider ip a hacky? It shows you all of the information you need to know about any of your network interfaces at a glance.

How about ifconfig?

hostname -I?

1
  • None of those are portable across systems? With ip addr you have to parse the output for the results, which changes with versions of IP. hostname -I is not on my machine. Neither is ifconfig.
    – cowlicks
    Commented Oct 21, 2018 at 0:07

Not the answer you're looking for? Browse other questions tagged .