在Linux中,您可以使用ifconfig
命令(在較舊的系統上)或ip
命令(在較新的系統上)來啟用或禁用網絡接口
使用ifconfig(適用于較舊的Linux發行版):
sudo ifconfig<interface> up
以啟用網絡接口,其中<interface>
是要啟用的網絡接口名稱(例如,eth0或ens33)。例如:sudo ifconfig eth0 up
sudo ifconfig<interface> down
以禁用網絡接口。例如:sudo ifconfig eth0 down
使用ip(適用于較新的Linux發行版):
sudo ip link set<interface> up
以啟用網絡接口,其中<interface>
是要啟用的網絡接口名稱(例如,eth0或ens33)。例如:sudo ip link set eth0 up
sudo ip link set<interface> down
以禁用網絡接口。例如:sudo ip link set eth0 down
請注意,這些命令需要管理員權限才能運行。因此,確保在命令前加上sudo
。