cmdref.net - Cheat Sheet and Example

cmdref.net is command references/cheat sheets/examples for system engineers.

User Tools

Site Tools


Sidebar








Cloud



Etc


Reference














.

os:linux:command:ifconfig



Linux Commands#network

ifconfig - How to use ifconfig command in Linux with examples

man ifconfig

NAME
       ifconfig - configure a network interface

SYNOPSIS
       ifconfig [-v] [-a] [-s] [interface]
       ifconfig [-v] interface [aftype] options | address ...



OPTIONS
       -a     display all interfaces which are currently available, even if down

       -s     display a short list (like netstat -i)

       up     This flag causes the interface to be activated.  It is implicitly specified if an address is
              assigned  to  the interface; you can suppress this behavior when using an alias interface by
              appending an - to the alias (e.g.  eth0:0-).  It is also  suppressed  when  using  the  IPv4
              0.0.0.0 address as the kernel will use this to implicitly delete alias interfaces.

       down   This flag causes the driver for this interface to be shut down.

       [-]promisc
              Enable  or  disable  the promiscuous mode of the interface.  If selected, all packets on the
              network will be received by the interface.


ifconfig -h

$ ifconfig -h
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) ec (Econet) x25 (generic X.25)
    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) ec (Econet)
    ash (Ash) x25 (CCITT X.25)


ifconfig command Example

How to check the interface

# ifconfig

# ifconfig eth0    <- only eth0
# ifconfig -a

-a display all interfaces which are currently available, even if down


How to check the only Communication state

$ ifconfig -s
Iface      MTU    RX-OK RX-ERR RX-DRP RX-OVR    TX-OK TX-ERR TX-DRP TX-OVR Flg
eth0      1500 636048634      0   1481 0      81199240      0      0      0 BMRU
lo       65536  1234171      0      0 0       1234171      0      0      0 LRU


How to Enable or Disable the interface

Enable the interface
# ifconfig eth0 up
Disable the interface
# ifconfig eth0 down


How to assign IP address

# ifconfig add eth0 192.168.1.10

# ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.1
# ifconfig del eth0 192.168.1.10


Promiscuous Mode of the interface

Check Promiscus mode
ifconfig

<UP,BROADCAST,RUNNING,MULTICAST>

<UP,BROADCAST,RUNNING,MULTICAST,PROMISC>
Enable Promiscus mode
# ifconfig [NIC name] promisc
Disable Promiscus mode
# ifconfig [NIC name] promisc off



os/linux/command/ifconfig.txt ยท Last modified: 2021/05/19 by admin

Page Tools