10

Is there a Linux command that visualizes configured network interfaces in a tree view, just like lsblk does for block devices?

The output of such a program could for example look like this (bottom-up-approach):

eth0   
└─bond0
  ├─bond0.42
  │ └─br42
  └─bond0.43
    └─br43
eth1
└─bond0
  ├─bond0.42
  │ └─br42
  └─bond0.43
    └─br43
tap100i0
└─br42
tap100i1
└─br43
tap101i0
└─br42
tap101i1
└─br43

or this (top-down-approach):

br42
├─bond0.42
│ └─bond0
│   ├─eth0
│   └─eth1
├─tap100i0
└─tap101i0
br43
├─bond0.43
│ └─bond0
│   ├─eth0
│   └─eth1
├─tap100i1
└─tap101i1

Note: I am not looking for a tool that produces this exact output, but rather asking if anyone knows a command with a similar result.

  • did you try ip addr ?? – Sidahmed Dec 31 '16 at 17:58
  • yes, but ip addr returns a flat list of network interfaces, not a hierarchical tree view – jlauinger Jan 2 '17 at 16:03
5

I have search for an option in existing utilities but I have not found any. Nevertheless the desired functionality is useful from my point of view. So I did a simple bash script that parses ip link show command and prints something similar to the desired output in the question:

$ ./nettree.sh -u
eth3
    bond1
       bond0
eth2
    bond0
eth1
    bond0
eth0
lupen3
    bond1
       bond0
lo
lxcbr0
virbr0
veth6404e35
    docker0

I pushed the script to github: https://github.com/zabojcampula/show-net-devices-tree

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.