问题原文
原帖链接 · Mike S · CC BY-SA 4.0
Is there any way to shut off a network interface on a Linux box from the command line? By shut off, I mean to make the link power down as per a Cisco switch's "shutdown" command. ip, and ifconfig and even rmmod <driver> when used to bring a port down do not disconnect link; the device on the other end still sees a connection even when one disables a port using those utilities/methods.
Technically, at a device level I'm sure it can be done because when I perform
ip link set em1 down
ip link set em1 up
...then during the "up" phase, the NIC does go off for about 3-4 seconds (as seen on a switch's port cabled to that NIC, and on the port's status LED).
What I'm looking for is a command line utility that will perform the task. I have CentOS 7.2 on a Dell R610 using the onboard Broadcom nics.
As to why...
It's really easy and useful to double check a network connection when you can bounce an interface in the switch.
"But there's lldp". Except when there's not, such as with a Layer 1 switch. (Google "Metamako" for more information). Being able to toggle a server network interface could verify cabling from 2000 miles away.
"But you can already do that on the switch side." Yes, and isn't it glorious? Would that the functionality were available to Server administrators, on the server side.
"But if you can't connect to the host, well then it's already dead." Think about systems with 8 live network interfaces. You can easily log in to a system via the onboard interface and have many PCIe nic's down.
已采纳解答
原帖链接 · Matthias Š · CC BY-SA 4.0
unfortunately it doesn't exist a general way in linux.
In the networking world it is very common to toggle a port "Cisco: shut / no shut, Juniper disable/enable" to identify or trigger autonegotiation.
In Linux you have to rely on the individual driver for your network card.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
