Lazyweb, a question: what is the simplest command that will give me a Linux machine’s IP address, and only that?
Conversation
Notices
-
Embed this notice
mhoye (mhoye@mastodon.social)'s status on Friday, 15-Nov-2024 11:47:50 JST mhoye -
Embed this notice
Michał "rysiek" Woźniak · 🇺🇦 (rysiek@mstdn.social)'s status on Friday, 15-Nov-2024 11:47:50 JST Michał "rysiek" Woźniak · 🇺🇦 @mhoye oh dear… :blobcatpopcornnom:
-
Embed this notice
Michał "rysiek" Woźniak · 🇺🇦 (rysiek@mstdn.social)'s status on Friday, 15-Nov-2024 11:54:20 JST Michał "rysiek" Woźniak · 🇺🇦 `ip -br a` is probably close enough to what you want.
if you know the interface name you can zero-in on it with:
`ip -br a s eth0`
Thing is, an interface can have multiple IPv4 and IPv6 addresses, obviously. In other words, "Linux machine's IP address" is just not clear enough a query to get a clear answer. You kind of need to narrow it down *somehow*, and that will be very dependent on the specific context of what you're trying to do…
-
Embed this notice
Xenotar (xenotar@mastodon.social)'s status on Friday, 15-Nov-2024 11:54:32 JST Xenotar @mhoye
old school: ifconfig -a
new school: ip address -
Embed this notice
Darcy Casselman (flyingsquirrel@mastodon.social)'s status on Friday, 15-Nov-2024 12:51:30 JST Darcy Casselman @mhoye `hostname -I`
-
Embed this notice
Jon Dubovsky (jond@mastodon.social)'s status on Friday, 15-Nov-2024 12:51:30 JST Jon Dubovsky @flyingsquirrel @mhoye second'ing this: hostname -I (capital I) will give you the non-loopback addr (or addrs, if the machine has multiple)
-
Embed this notice
Michał "rysiek" Woźniak · 🇺🇦 (rysiek@mstdn.social)'s status on Friday, 15-Nov-2024 12:51:30 JST Michał "rysiek" Woźniak · 🇺🇦 @jond ha! I learned something new today!
-
Embed this notice