在較新的 Debian 版本中,ifconfig
命令已被棄用,取而代之的是 ip
命令。不過,如果你仍在使用需要 ifconfig
的環境,或者是在較舊的 Debian 版本中,以下是一些使用 ifconfig
進行網絡設置的技巧:
如果你的 Debian 系統上沒有安裝 ifconfig
,可以通過以下命令進行安裝:
sudo apt update
sudo apt install net-tools -y
ifconfig -a
ifconfig eth0
sudo ifconfig eth0 192.168.1.100 netmask 255.255.255.0 up
sudo ifconfig eth0 down
sudo ifconfig eth0 up
sudo ifconfig eth0 broadcast 192.168.1.255
sudo ifconfig eth0 mtu 1500
sudo ifconfig eth0 release
ifconfig eth0 | grep hw
ifconfig
命令設置的配置在系統重啟后會被丟失,要使配置永久生效,可以編輯 /etc/network/interfaces
文件或將其添加到啟動腳本中。請注意,盡管 ifconfig
命令在某些環境中仍然可用,但在較新的 Debian 版本中,建議使用 ip
命令來執行網絡配置和管理任務。