1.用法
Usage:
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
[add <address>[/<prefixlen>]]
[del <address>[/<prefixlen>]]
[[-]broadcast [<address>]] [[-]pointopoint [<address>]]
[netmask <address>] [dstaddr <address>] [tunnel <address>]
[outfill <NN>] [keepalive <NN>]
[hw <HW> <address>] [metric <NN>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] ...
2.-a 显示全部接口的信息
root@ubuntu:~# ifconfig -a
ens33 Link encap:Ethernet HWaddr 00:0c:29:ac:70:8e
inet addr:192.168.0.197 Bcast:192.168.0.255 Mask:255.255.255.0
inet6 addr: fe80::ec16:f92d:eb3c:4819/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:607554398 errors:0 dropped:0 overruns:0 frame:0
TX packets:11980199 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:882589050431 (882.5 GB) TX bytes:791708732 (791.7 MB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:6527 errors:0 dropped:0 overruns:0 frame:0
TX packets:6527 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:455272 (455.2 KB) TX bytes:455272 (455.2 KB)
注意:
lo表示主机的回环网卡,是一种特殊的网络接口,不与任何实际设备连接,而是完全由软件实现。
3.-s显示摘要信息
root@ubuntu:~# ifconfig -s
Iface MTU Met RX-OK RX-ERR RX-DRP RX-OVR TX-OK TX-ERR TX-DRP TX-OVR Flg
ens33 1500 0 607554923 0 0 0 11980202 0 0 0 BMRU
lo 65536 0 6527 0 0 0 6527 0 0 0 LRU
root@ubuntu:~#
4.promisc 设置网卡promiscuous模式
ifconfig ens33 promisc//设置
ifconfgi ens33 -promisc//取消
5.up 和down
开启和关闭网卡
ifconfig lo up
ifconfig lo down
6.设置临时ip地址
重启就无效了
ifconfig ens33 192.168.0.105
7.设置临时mac地址
重启后无效
ifconfig ens33 hw ether 00:23:34:45:56:67