11

As I know, in a Linux shell environment, I could list the networks links in any specific namespace with ip, like:

ip netns exec <namespace> ip link show

My question is:

If I have multiple net namespaces, how to list all the links in all the namespaces with a simple command? Or I have to write a script to do so?

Dharman
  • 30,962
  • 25
  • 85
  • 135
Qiu Yangfan
  • 871
  • 11
  • 25

1 Answers1

5

You can simply do:

ip link show; ip -all netns exec ip link show

Internally this just does what your script would do - it steps through all namespaces and runs the command.

Sidepipe
  • 89
  • 1
  • 2
  • Would you let me know your OS and version? I tried on both my Debian and CentOS, both get: Option "-all" is unknown, try "ip -help". And my version: ip utility, iproute2-ss140804 – Qiu Yangfan Sep 07 '17 at 13:59
  • 1
    I'm not sure which versions of iproute2 are included with which oses, but the -all option was introduced around February 2015 ( so around the official 4.0.0 release... not checked exactly which. ) Look for updated iproute2 packages. Otherwise you'll have to use a script. – Sidepipe Sep 08 '17 at 16:07