大网数据广告活动
服务器运维问答

How to physically shut off network interface in Linux (Redhat/Centos)

· 52CE 我爱测

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 use…

问题原文

原帖链接 · 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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-09-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。