ip link 和 ip addr 输出意义

Zab*_*ula 23 linux networking ip ethernet

我正在寻找一个解释,命令的输出ip linkip addr在 linux 机器上的含义到底是什么。

# ip link
3: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT qlen 1000
link/ether 00:a1:ba:51:4c:11 brd ff:ff:ff:ff:ff:ff
4: eth1: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT qlen 1000
link/ether 00:a1:ba:51:4c:12 brd ff:ff:ff:ff:ff:ff
Run Code Online (Sandbox Code Playgroud)

LOWER_UP,NO-CARRIER和其他标志究竟是什么?我在http://download.vikis.lt/doc/iproute-doc-2.6.32/ip-cref.ps找到了一个参考,但它不包含完整的信息,手册页不够详细。

xhi*_*nne 27

这些是接口的标志。它们记录在netdevice(7)手册页中。以下是相关部分(按字母顺序重新排序):

IFF_ALLMULTI      Receive all multicast packets.
IFF_AUTOMEDIA     Auto media selection active.
IFF_BROADCAST     Valid broadcast address set.
IFF_DEBUG         Internal debugging flag.
IFF_DORMANT       Driver signals dormant (since Linux 2.6.17)
IFF_DYNAMIC       The addresses are lost when the interface goes down.
IFF_ECHO          Echo sent packets (since Linux 2.6.25)
IFF_LOOPBACK      Interface is a loopback interface.
IFF_LOWER_UP      Driver signals L1 up (since Linux 2.6.17)
IFF_MASTER        Master of a load balancing bundle.
IFF_MULTICAST     Supports multicast
IFF_NOARP         No arp protocol, L2 destination address not set.
IFF_NOTRAILERS    Avoid use of trailers.
IFF_POINTOPOINT   Interface is a point-to-point link.
IFF_PORTSEL       Is able to select media type via ifmap.
IFF_PROMISC       Interface is in promiscuous mode. 
IFF_RUNNING       Resources allocated.
IFF_SLAVE         Slave of a load balancing bundle.
IFF_UP            Interface is running.
Run Code Online (Sandbox Code Playgroud)

因此,LOWER_UP意味着在物理级别存在信号(即在网络接口中插入了活动的东西)。NO-CARRIER, 正好相反:在物理层面上没有检测到信号。

  • 有趣的是如何在`netdevice(7)`中_not_记录`NO-CARRIER`... (3认同)
  • 这是因为“NO-CARRIER”不是您可以获取或设置的实际标志。它被定义为“IFF_UP”而不是“IFF_RUNNING”的组合。 (3认同)