在 CentOS 系统中,要禁用网络接口,可以使用 ifconfig 命令将接口的 IP 地址设置为 127.0.0.1,或者使用 ip 命令将接口的状态设置为 down
方法一:使用 ifconfig 命令
ifconfig -a
eth0,运行以下命令将 IP 地址设置为 127.0.0.1:sudo ifconfig eth0 127.0.0.1
这将使网络接口 eth0 无法与其他设备通信,从而达到禁用的目的。
方法二:使用 ip 命令
ip addr show
eth0,运行以下命令将接口状态设置为 down:sudo ip link set eth0 down
这将立即禁用网络接口 eth0。如果以后需要重新启用该接口,可以使用以下命令将接口状态设置为 up:
sudo ip link set eth0 up
注意:在执行这些命令时,请确保具有 root 权限。