Get every IP except for the loopback device
up vote
0
down vote
favorite
I need to get every IP of an host PC over the shell, except for the loopback or localhost devices.
If I use ip addr show I have the loopback devices with it. Also I cannot ask for the ip addr show [device] because I actually don't know the device name.
Later I following to get only the ips.
ip addr | grep "inet" | awk '{print $2}' | cut -d/ -f1
shell ssh ip
add a comment |
up vote
0
down vote
favorite
I need to get every IP of an host PC over the shell, except for the loopback or localhost devices.
If I use ip addr show I have the loopback devices with it. Also I cannot ask for the ip addr show [device] because I actually don't know the device name.
Later I following to get only the ips.
ip addr | grep "inet" | awk '{print $2}' | cut -d/ -f1
shell ssh ip
1
please note thatawkcangrepandcut, your expression can be rewrite asip addr | awk '$1 == "inet" { split($2,I,"/"); print I[1]}'(which also yield lo0, but filter out ipv6).
– Archemar
2 days ago
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I need to get every IP of an host PC over the shell, except for the loopback or localhost devices.
If I use ip addr show I have the loopback devices with it. Also I cannot ask for the ip addr show [device] because I actually don't know the device name.
Later I following to get only the ips.
ip addr | grep "inet" | awk '{print $2}' | cut -d/ -f1
shell ssh ip
I need to get every IP of an host PC over the shell, except for the loopback or localhost devices.
If I use ip addr show I have the loopback devices with it. Also I cannot ask for the ip addr show [device] because I actually don't know the device name.
Later I following to get only the ips.
ip addr | grep "inet" | awk '{print $2}' | cut -d/ -f1
shell ssh ip
shell ssh ip
asked 2 days ago
JackGrinningCat
1234
1234
1
please note thatawkcangrepandcut, your expression can be rewrite asip addr | awk '$1 == "inet" { split($2,I,"/"); print I[1]}'(which also yield lo0, but filter out ipv6).
– Archemar
2 days ago
add a comment |
1
please note thatawkcangrepandcut, your expression can be rewrite asip addr | awk '$1 == "inet" { split($2,I,"/"); print I[1]}'(which also yield lo0, but filter out ipv6).
– Archemar
2 days ago
1
1
please note that
awk can grepand cut, your expression can be rewrite as ip addr | awk '$1 == "inet" { split($2,I,"/"); print I[1]}' (which also yield lo0, but filter out ipv6).– Archemar
2 days ago
please note that
awk can grepand cut, your expression can be rewrite as ip addr | awk '$1 == "inet" { split($2,I,"/"); print I[1]}' (which also yield lo0, but filter out ipv6).– Archemar
2 days ago
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
In the end I used.
ip addr show scope global
I actually do not know if I'll miss a IP in environment with more complicated setups but for my simple test network it should work.
Actually I didn't found the something like everything but not loopback. But even if I started with that idea. This is good enough for now.
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
In the end I used.
ip addr show scope global
I actually do not know if I'll miss a IP in environment with more complicated setups but for my simple test network it should work.
Actually I didn't found the something like everything but not loopback. But even if I started with that idea. This is good enough for now.
add a comment |
up vote
1
down vote
In the end I used.
ip addr show scope global
I actually do not know if I'll miss a IP in environment with more complicated setups but for my simple test network it should work.
Actually I didn't found the something like everything but not loopback. But even if I started with that idea. This is good enough for now.
add a comment |
up vote
1
down vote
up vote
1
down vote
In the end I used.
ip addr show scope global
I actually do not know if I'll miss a IP in environment with more complicated setups but for my simple test network it should work.
Actually I didn't found the something like everything but not loopback. But even if I started with that idea. This is good enough for now.
In the end I used.
ip addr show scope global
I actually do not know if I'll miss a IP in environment with more complicated setups but for my simple test network it should work.
Actually I didn't found the something like everything but not loopback. But even if I started with that idea. This is good enough for now.
answered 2 days ago
JackGrinningCat
1234
1234
add a comment |
add a comment |
Thanks for contributing an answer to Unix & Linux Stack Exchange!
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- Please be sure to answer the question. Provide details and share your research!
But avoid …
- Asking for help, clarification, or responding to other answers.
- Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f487141%2fget-every-ip-except-for-the-loopback-device%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
1
please note that
awkcangrepandcut, your expression can be rewrite asip addr | awk '$1 == "inet" { split($2,I,"/"); print I[1]}'(which also yield lo0, but filter out ipv6).– Archemar
2 days ago