ifconfig 的语法为
ifconfig [-a] [-V] [-s] <interface> [[<AF>] <address>]
[[-]broadcast [<address>]]
[netmask <address>]
[up|down]
其中 interface 为网卡名
address 为IP 地址
broadcast 表示设置广播
netmask 表示设置子网掩码
地址其后的address 为广播地址的IP
其后的address 为子网掩码的IP up down 设置当前网卡的状态up
表示启用当前网卡down 表示关闭当前网卡
Ifconfig 的常用参数说明如下
-a 查看所有网卡状态
-V 查看ifconfig 命令的版本信息
-s 查看统计信息
[root@test]# ifconfig -V
net-tools 1.60
ifconfig 1.42 (2001-04-13)
[root@test]# ifconfig -s
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0 1500 0 5244509 0 0 0 51967 0 0 0 BMRU
eth1 1500 0 46693850 0 0 0 315084 0 0 0 BMRU
lo 16436 0 25733 0 0 0 25733 0 0 0 LRU
[root@test]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:16:3E:00:03:D6
inet addr:10.51.180.189 Bcast:10.51.183.255 Mask:255.255.248.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:5233071 errors:0 dropped:0 overruns:0 frame:0
TX packets:51953 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:261883477 (249.7 MiB) TX bytes:80421564 (76.6 MiB)
Interrupt:164
eth1 Link encap:Ethernet HWaddr 00:16:3E:00:08:93
inet addr:101.200.1.46 Bcast:101.200.3.255 Mask:255.255.252.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:46662128 errors:0 dropped:0 overruns:0 frame:0
TX packets:305055 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:2350771127 (2.1 GiB) TX bytes:113409312 (108.1 MiB)
Interrupt:163
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:16436 Metric:1
RX packets:25733 errors:0 dropped:0 overruns:0 frame:0
TX packets:25733 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7519916 (7.1 MiB) TX bytes:7519916 (7.1 MiB)