我在下面做了一些测试。似乎ifdown ens32
没有关闭界面。并且ip link
仍然显示UP
。只会ip link set ens32 down
关闭接口。那么这里有什么问题呢?为什么ifdown无法关闭接口?
root:[~]# cat /etc/*release*
Oracle Linux Server release 7.6
NAME="Oracle Linux Server"
VERSION="7.6"
ID="ol"
VARIANT="Server"
VARIANT_ID="server"
VERSION_ID="7.6"
PRETTY_NAME="Oracle Linux Server 7.6"
ANSI_COLOR="0;31"
CPE_NAME="cpe:/o:oracle:linux:7:6:server"
HOME_URL="https://linux.oracle.com/"
BUG_REPORT_URL="https://bugzilla.oracle.com/"
ORACLE_BUGZILLA_PRODUCT="Oracle Linux 7"
ORACLE_BUGZILLA_PRODUCT_VERSION=7.6
ORACLE_SUPPORT_PRODUCT="Oracle Linux"
ORACLE_SUPPORT_PRODUCT_VERSION=7.6
Red Hat Enterprise Linux Server release 7.6 (Maipo)
Oracle Linux Server release 7.6
cpe:/o:oracle:linux:7:6:server
root:[~]#
root:[~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:50:56:31:a8:12 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:33:cf:a3 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:33:cf:a3 brd ff:ff:ff:ff:ff:ff
root:[~]# ifdown ens32
Device 'ens32' successfully disconnected.
root:[~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens32: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc pfifo_fast state UP mode DEFAULT group default qlen 1000
link/ether 00:50:56:31:a8:12 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:33:cf:a3 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:33:cf:a3 brd ff:ff:ff:ff:ff:ff
root:[~]# ip link set ens32 down
root:[~]# ip link
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN mode DEFAULT group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
2: ens32: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast state DOWN mode DEFAULT group default qlen 1000
link/ether 00:50:56:31:a8:12 brd ff:ff:ff:ff:ff:ff
3: virbr0: <NO-CARRIER,BROADCAST,MULTICAST,UP> mtu 1500 qdisc noqueue state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:33:cf:a3 brd ff:ff:ff:ff:ff:ff
4: virbr0-nic: <BROADCAST,MULTICAST> mtu 1500 qdisc pfifo_fast master virbr0 state DOWN mode DEFAULT group default qlen 1000
link/ether 52:54:00:33:cf:a3 brd ff:ff:ff:ff:ff:ff
root:[~]#
没有区别是不正确的。
ifup
和ifdown
read/etc/network/interfaces
,除了启动和关闭接口之外,它们还在 中执行许多脚本/etc/network
,这些脚本为各种事物(如 DHCP)提供了钩子。另一方面,
ip link ...
(新变体)和ifconfig ... up/down
(旧变体)直接设置接口的状态,而不执行任何在接口上升和下降时可能需要的额外操作。因此,如果
ifdown
不起作用,则您的系统可能未配置为使用经典/etc/network/interfaces
系统(例如,因为它使用systemd
,它的所有操作都不同),或者某些首先执行的脚本中的某处出现错误,或者可能是其他一些原因。ip
新命令(新的做事方式)和旧命令之间没有区别——曾经有ipconfig
,netstat
和. 请参阅此处进行比较:arp
route
https://p5r.uk/blog/2010/ifconfig-ip-comparison.html
https://www.tecmint.com/ifconfig-vs-ip-command-comparing-network-configuration/
但是,
ifup
并且ifdown
是网络脚本的一部分,它比上面列出的每个命令都做得更多。也许您的网络是由 wicked 或其他网络管理员管理的。尝试查看是否可能
ifdown
是某些网络管理包的一部分 - 这因发行版而异。因此,也许您需要更改网络配置工具管理网络的方式。