ip -details link show
type在第三行, loopback 物理 wifi等没有type
ip -details -json link show | jq --join-output ' .[] | if .ifname != null then .ifname, " ", if .linkinfo.info_kind != null then .linkinfo.info_kind else empty end, " ", if .linkinfo.info_slave_kind != null then .linkinfo.info_slave_kind else empty end, "\n" else empty end '
#!/bin/bash # Arguments: $1: Interface ('grep'-regexp). # For virtual devices, device type is shown on the third line. # Static list of types (from `ip link help`). NOTE: On my machine, not all types are listed there, e.g. the type `tun`. And the list of types may change over time. So do not ultimately rely on this list here!: TYPES=(bareudp bond bond_slave bridge can dummy erspan geneve gre gretap hsr ifb ip6erspan ip6gre ip6gretap ip6tnl ipip ipoib ipvlan ipvtap lowpan macsec macvlan macvtap netdevsim nlmon rmnet sit tap tun vcan veth vlan vrf vti vxcan vxlan xfrm) iface="$1" for type in "${TYPES[@]}"; do ip link show type "${type}" | grep -E '^[0-9]+:' | cut -d ':' -f 2 | sed 's|^[[:space:]]*||' | while read _if; do echo "${_if}:${type}" done | grep "^${iface}" done true
最好脚本
( sudo ip -details -j l | jq -r '.[]|"@", .ifname, .link_type, .linkinfo.info_data.type, .linkinfo.info_kind, .linkinfo.info_slave_kind' | tr '\n' ' ' | tr '@' '\n' ; echo ) | column -t
iproute - iproute2: How to display the TYPE of a network devices? - Unix & Linux Stack Exchange
标签:info,kind,ip,link,linkinfo,type From: https://www.cnblogs.com/dissipate/p/17034998.html