假设我们有无线接口wlan0。ip link set wlan0 up/down实际上是做什么的?电源和电源关闭NIC?很多网络配置指南都会漫不经心地将其描述为“提升界面”,但这到底意味着什么呢?
发布于 2018-07-08 22:34:42
当您将接口向上/向下打开时,您只是在驱动程序上设置一个标志,表明接口的状态是向上或向下的。NIC仍然是接通的,可以参加WOL (唤醒局域网)等。
如果您查看接口的输出,就会在这里显示状态标志:
$ ip a l eth1
3: eth1: mtu 1500 qdisc pfifo_fast state UP qlen 1000
link/ether 08:00:27:72:14:26 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.101/24 brd 192.168.56.255 scope global eth1
valid_lft forever preferred_lft forever
inet6 fe80::a00:27ff:fe72:1426/64 scope link
valid_lft forever preferred_lft forever状态上升
如果我告诉ip将其放入下状态:
$ ip l set eth1 down
$ ip a l eth1
3: eth1: mtu 1500 qdisc pfifo_fast state DOWN qlen 1000
link/ether 08:00:27:72:14:26 brd ff:ff:ff:ff:ff:ff
inet 192.168.56.101/24 brd 192.168.56.255 scope global eth1
valid_lft forever preferred_lft forever很简单。使用ethtool进一步询问NIC。
$ ethtool eth1
Settings for eth1:
Supported ports: [ TP ]
Supported link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Supported pause frame use: No
Supports auto-negotiation: Yes
Advertised link modes: 10baseT/Half 10baseT/Full
100baseT/Half 100baseT/Full
1000baseT/Full
Advertised pause frame use: No
Advertised auto-negotiation: Yes
Speed: 1000Mb/s
Duplex: Full
Port: Twisted Pair
PHYAD: 0
Transceiver: internal
Auto-negotiation: on
MDI-X: Unknown (auto)
Supports Wake-on: umbg
Wake-on: d
Current message level: 0x00000007 (7)
drv probe link
Link detected: no这个输出的关键部分是Link detected: no。那是因为它处于低谷状态。如果我们把它拿回来:
$ ethtool eth1 | grep Link
Link detected: yes在这种情况下,Link detected: yes意味着网卡已经启动,并且可以检测插入其中的以太网电缆。
上面使用的
注意,我使用的是命令的速记符号:
a == addrl == list还有更多..。ip命令“足够聪明”,可以确定您使用的是哪个命令或哪个子命令,并且可以推断它。
https://unix.stackexchange.com/questions/454196
复制相似问题