List all IP's using the command "ip" and not "ifconfig"

987 views Asked by At

I am trying to find a command that can list all the IPs (only the ip's) using the "ip" command in ubuntu 20.04.

Ip a outputs way too much, so I tried to output only a bit of it without success using ip -c -6 -o a or ip -c -4 -o a for ipv4.

Does anyone know how to list simply all the IPs of the system using the ip command. I can't find anything except by using ifconfig, which I don't want to instal just to run this script.

Thanks for your help !

2

There are 2 answers

0
Ivan On BEST ANSWER

Please, try this command

hostname -I
0
Poli On

Parse ifconfig to get only my IP address using Bash

Founded someone also replying for ip addr but I will use hostname -I as @Ivan said.