首页 > 其他分享 >ip link show type

ip link show type

时间:2023-01-08 18:00:55浏览次数:50  
标签:info kind ip link linkinfo type

 

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

 

 

networking - How to determine the logical type of a linux network device - Unix & Linux Stack Exchange

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

相关文章

  • P9_组件-swiper和swiper-item的基本用法
    swiper和swiper-item组件的基本使用实现如图的轮播图效果:swiper组件的常用属性list.wxml<swiperclass="swiper-container"indicator-dotsautoplayinterv......
  • P9_组件-swiper和swiper-item的基本用法
    swiper和swiper-item组件的基本使用实现如图的轮播图效果:swiper组件的常用属性list.wxml<swiperclass="swiper-container"indicator-dotsautoplayinterv......
  • pip 基本问题
    pip语法错误pip换源更新错误无模板Ignoring警告                  问题一(pip语法错误)            ......
  • pip 基本问题
                     问题一(pip语法错误)                  piplistFile"<stdin>",line1......
  • gcc linking order
    g++-o11.cpp-lpng16#correctg++1.cpp-lpng16-o1#correctg++-lpng161.cpp-o1#wrongg++-o1-lpng161.cpp#wrongLink1 |  Link2 | Link3......
  • js原型prototype和__proto__
    functionFun(){console.log("我是一个函数")}letfun=newFun()//每一个函数都会有一个prototype属性称为显式原型属性console.log(Fun.prototyp......
  • P1073 [NOIP2009 提高组] 最优贸易 强联通分量+缩点
    //题意:给出有向图,有环(SCC),每个节点有一个商品值,小明想从1点走向n点,同时想要进行一次贸易,即从路线上某个点买入商品,又在某个节点卖出,询问最大收益是多少(如果收益为负数......
  • Mac Snipaste 不仅仅是截图工具,不在菜单栏显示,怎么样修改快捷键
    官网下载:https://www.snipaste.comSnipaste免费,支持Windows、Mac,Windows上的功能相当多而且,Mac也够用了不仅仅是个截图工具,具有强大功能:截图贴图(直接将截图贴在......
  • JavaScript-删除节点,克隆节点,注册事件,删除事件
    JavaScript-删除节点,克隆节点,注册事件,删除事件目录JavaScript-删除节点,克隆节点,注册事件,删除事件5.节点操作5.5删除节点5.6复制节点(克隆节点)5.8三种动态创建元素......
  • DevOps实战系列【第十四章-完结篇】:Jenkins Pipeline最佳实践案例
    个人亲自录制全套DevOps系列实战教程:​​手把手教你玩转DevOps全栈技术​​我们将之前的案例,使用流水线构建一下搭建一个Jenkinsfile模型pipeline{agentanystage......