Linux ifconfig 实用例子


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
Tags:

One Response

  1. 手机回收 04 August 2015

Leave a Reply