ifconfig
是一個用于配置和顯示 Linux 內核中網絡接口的命令行實用程序。在 Debian 系統中,它同樣適用。ifconfig
命令允許用戶查看和修改網絡接口的設置,如 IP 地址、子網掩碼、廣播地址等。
以下是 ifconfig
命令的一些常用選項和解釋:
ifconfig
:不帶任何參數運行此命令將顯示系統中所有活動網絡接口的詳細信息。
ifconfig <interface>
:使用此選項,您可以查看特定網絡接口的信息。將 <interface>
替換為您要查看的網絡接口名稱,如 eth0
或 wlan0
。
ifconfig <interface> up
:此選項用于啟用指定的網絡接口。將 <interface>
替換為您要啟用的網絡接口名稱。
ifconfig <interface> down
:此選項用于禁用指定的網絡接口。將 <interface>
替換為您要禁用的網絡接口名稱。
ifconfig <interface> hw ether <mac_address>
:使用此選項,您可以更改指定網絡接口的硬件(MAC)地址。將 <interface>
替換為您要更改的網絡接口名稱,將 <mac_address>
替換為您要設置的新 MAC 地址。
ifconfig <interface> inet <ip_address>
:此選項用于為指定的網絡接口分配 IP 地址。將 <interface>
替換為您要配置的網絡接口名稱,將 <ip_address>
替換為您要分配的 IP 地址。
ifconfig <interface> netmask <subnet_mask>
:此選項用于設置指定網絡接口的子網掩碼。將 <interface>
替換為您要配置的網絡接口名稱,將 <subnet_mask>
替換為您要設置的子網掩碼。
ifconfig <interface> broadcast <broadcast_address>
:此選項用于設置指定網絡接口的廣播地址。將 <interface>
替換為您要配置的網絡接口名稱,將 <broadcast_address>
替換為您要設置的廣播地址。
請注意,ifconfig
命令在某些 Linux 發行版中可能已被棄用,取而代之的是 ip
命令。盡管如此,ifconfig
仍然在許多系統中廣泛使用。