Skip to content

Instantly share code, notes, and snippets.

@mjf
Created July 14, 2023 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mjf/a1eeeab782a3938fae3b7d444887e004 to your computer and use it in GitHub Desktop.
Save mjf/a1eeeab782a3938fae3b7d444887e004 to your computer and use it in GitHub Desktop.
Get interface info
(
  echo -e 'INDEX,NAME,TYPE,KIND,LINK,LINDEX'
  sudo ip -all netns exec ip -details -j -p link show |
  sed '/^netns:/d' |
  jq -n '[inputs] | add' |
  jq -r '.[] | "\(.ifindex),\(.ifname),\(.link_type),\(.linkinfo.info_kind),\(.link),\(.link_index)"' |
  sort -unk1
) |
column -ts,
INDEX  NAME             TYPE      KIND       LINK         LINDEX
1      lo               loopback  null       null         null
2      wan0             ether     null       null         null
3      vpn0             none      wireguard  null         null
4      virbr0           ether     bridge     null         null
7      kube0            ether     dummy      null         null
8      cni0             ether     bridge     null         null
14     cilium_net       ether     veth       cilium_host  null
15     cilium_host      ether     veth       cilium_net   null
16     cilium_vxlan     ether     vxlan      null         null
82     eth0             ether     veth       null         83
83     lxca8b71ab4633f  ether     veth       null         82
84     eth0             ether     veth       null         85
85     lxc584b19f2eddc  ether     veth       null         84
88     eth0             ether     veth       null         89
89     lxc383ec70c422b  ether     veth       null         88
124    eth0             ether     veth       null         125
125    lxc3e891029a3cd  ether     veth       null         124
232    eth0             ether     veth       null         233
233    lxc4527b726770f  ether     veth       null         232
234    eth0             ether     veth       null         235
235    lxc44dae241c6d0  ether     veth       null         234
236    eth0             ether     veth       null         237
237    lxc7cda37496449  ether     veth       null         236
240    eth0             ether     veth       null         241
241    lxcad34dcf60657  ether     veth       null         240
242    eth0             ether     veth       null         243
243    lxc32ef1e76ed7a  ether     veth       null         242
245    lxc_health       ether     veth       null         244
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment