ifconfig 的全寫是 “interface configuration”, 是在 Linux/Unix 系統的網卡管理工具, 可以顯示, 管理及查詢網卡狀態, 以下是 ifconfig 的實用例子。
直接輸入 “ifconfig” 而不加入任何參數, 會顯示所有 active 的網卡資料:
# ifconfig
加上 -a 參數會顯示所有網卡資料, 包括 active 及 inactive 的網卡:
# ifconfig -a
顯示個別網卡資料, 在 ifconfig 後面加上網卡名稱即可, 例如只想檢查 eth0 的資料:
# ifconfig eth0
要啟動網卡, 除了可以用 ifup 外, 用 ifconfig 也可以, 例如要啟動 eth0:
# ifconfig eth0 up
將以上指令的 up 換成 down, 可以停止網卡:
# ifconfig eth0 down
給個別網卡分配 IP 地址, 例如在 eth0 分配 Ip 192.168.1.101:
# ifconfig eth0 192.168.1.101
加上 “mtu” 參數可以設定網卡的 MTU, 例如設定 eth0 的 MTU 為 1000:
10. How to Change MTU for an Network Interface
# ifconfig eth0 mtu 1000
ifconfig 也可以為網卡加入 IP 別名:
13. How to Add New Alias to Network Interface
# ifconfig eth0:0 192.168.1.111
刪除網卡的 IP 別名:
# ifconfig eth0:0 down
看过留名,支持下