【问题标题】:How to extract eth0 interface name from eth0@if10 in a kubernetes container using ip addr如何使用 ip addr 从 kubernetes 容器中的 eth0@if10 中提取 eth0 接口名称
【发布时间】:2018-05-08 21:24:45
【问题描述】:

运行ip地址:

1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
3: eth0@if10: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1460 qdisc noqueue state UP group default
    link/ether 0a:58:0a:00:00:07 brd ff:ff:ff:ff:ff:ff link-netnsid 0
    inet 10.0.0.7/24 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 fe80::e837:feff:fe5c:c912/64 scope link
       valid_lft forever preferred_lft forever

ip addr 有没有办法返回 eth0 而不是 eth0@if10 ? 我看到 ifconfig 确实将其列为 eth0 而不是 eth0@if10

【问题讨论】:

    标签: linux kubernetes ip containers


    【解决方案1】:

    如果您只是获取@ 左侧的条目,请使用以下内容。

    ip a | cut -sf1 -d@
    

    如果您想针对特定接口,您可以在之前添加更多过滤器。

    【讨论】:

      猜你喜欢
      • 2023-03-30
      • 2016-01-06
      • 1970-01-01
      • 1970-01-01
      • 2012-02-28
      • 1970-01-01
      • 2017-05-04
      • 2018-11-17
      • 2022-10-25
      相关资源
      最近更新 更多