ifconfig命令的全称是network interface configuring, 用来配置Linux系统中的网卡信息。使用ifconfig命令配置的网卡配置信息,只是临时生效的,当网卡或者是机器重启,配置就会消失。只有通过修改配置文件才可以永久保存配置信息了。
ifconfig的常用参数
[root@centoss8 ~]#ifconfig --help
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>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] ...
<HW>=Hardware Type.
List of possible hardware types:
loop (Local Loopback) slip (Serial Line IP) cslip (VJ Serial Line IP)
slip6 (6-bit Serial Line IP) cslip6 (VJ 6-bit Serial Line IP) adaptive (Adaptive Serial Line IP)
ash (Ash) ether (Ethernet) ax25 (AMPR AX.25)
netrom (AMPR NET/ROM) rose (AMPR ROSE) tunnel (IPIP Tunnel)
ppp (Point-to-Point Protocol) hdlc ((Cisco)-HDLC) lapb (LAPB)
arcnet (ARCnet) dlci (Frame Relay DLCI) frad (Frame Relay Access Device)
sit (IPv6-in-IPv4) fddi (Fiber Distributed Data Interface) hippi (HIPPI)
irda (IrLAP) x25 (generic X.25) infiniband (InfiniBand)
eui64 (Generic EUI-64)
<AF>=Address family. Default: inet
List of possible address families:
unix (UNIX Domain) inet (DARPA Internet) inet6 (IPv6)
ax25 (AMPR AX.25) netrom (AMPR NET/ROM) rose (AMPR ROSE)
ipx (Novell IPX) ddp (Appletalk DDP) ash (Ash)
x25 (CCITT X.25)
[root@centoss8 ~]#
关闭、启动网卡
![](https://img-blog.csdnimg.cn/ae6b0086dc1f429dbd33190d2369a2f4.png)
添加删除IP地址
![](https://img-blog.csdnimg.cn/8462879c3129417cb19be49b8d473fa8.png)
配置IP地址
[root@centoss8 ~]#ifconfig eth0 192.168.1.23 netmask 255.255.255.0
ifconfig修改网卡mac地址
[root@centoss8 ~]#ifconfig eth0 down
[root@centoss8 ~]#ifconfig eth0 hw ether 00:0c:29:d0:3f:68
[root@centoss8 ~]#ifconfig
eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500
inet 10.0.0.150 netmask 255.255.255.0 broadcast 10.0.0.255
ether 00:0c:29:d0:3f:68 txqueuelen 1000 (Ethernet)
RX packets 301 bytes 27047 (26.4 KiB)
RX errors 0 dropped 0 overruns 0 frame 0
TX packets 205 bytes 27379 (26.7 KiB)
TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0