示例:

[root@localhost ~]# ifconfig # 查看网络接口信息
[root@localhost ~]# ifconfig eth0 down # 禁用eth0网卡
[root@localhost ~]# ifconfig eth0 up # 启用eth0网卡
[root@localhost ~]# ifconfig eth0 192.168.2.10 # 配置ip地址
[root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 # 配置ip地址
[root@localhost ~]# ifconfig eth0 192.168.2.10 netmask 255.255.255.0 broadcast 192.168.2.255 # 配置ip地址
[root@localhost ~]# ifconfig enp0s3 hw ether 00:AA:BB:CC:DD:EE # 修改mac地址
[root@localhost ~]# ifconfig eth0 add 33ffe:3240:800:1005::2/64    #为网卡eth0配置IPv6地址
[root@localhost ~]# ifconfig eth0 del 33ffe:3240:800:1005::2/64    #为网卡eth0删除IPv6地址
[root@localhost ~]# ifconfig eth0 arp    #开启网卡eth0 的arp协议
[root@localhost ~]# ifconfig eth0 -arp   #关闭网卡eth0 的arp协议
[root@localhost ~]# ifconfig eth0 mtu 1500    #设置能通过的最大数据包大小为 1500 bytes

用法:

  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.

 可能的硬件类型列表:

    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) ec (Econet) x25 (generic X.25) 

    infiniband (InfiniBand) eui64 (Generic EUI-64) 

  <AF>=Address family. Default: inet

  可能的地址族列表:

    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) ec (Econet) 

    ash (Ash) x25 (CCITT X.25)