Skip to content

ifconfig command on Linux (configures network interface)

The ifconfig command in Linux creates and configures network interfaces and their parameters. This operation is generally done during the system loading process. If no parameters are passed, it displays the settings of the active interfaces.

The ifconfig command is no longer used in distributions, the use of the ip command is preferred.

The ifconfig parameters can be:

  • interface: It is the name of the network interface. This is usually the name of the driver followed by a unit number. For example, eth0 for the first ethernet network device;
  • up: This parameter enables the network interface for use;
  • down: This parameter disables the network interface;
  • [-] arp: Enables or disables the use of the ARP (Address) protocol Resolution Protocol);
  • [-] promisc: Enables or disables the promiscuous mode of an interface. In this mode it will receive all network packets;
  • mtu num: Configures the MTU (Maximum Transfer Unit) to num on an interface;
  • address: Configures an IP address for the interface;
  • netmask mask: Configures a certain subnet mask for the interface.

Examples:

$ ifconfig
eth0 Link Encap:Ethernet HWaddr 00:50:FC: 34:7 E:1E
inet addr:200.150.34.188 Bcast:255.255.255.255 Mask:255.255.248.0
inet6 addr: fe80: :250:fcff:fe 34:7 e1e/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37120678 errors:0 dropped:0 overruns:0 frame:0
TX packets:716794 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:3034722143 (2894.1 Mb) TX bytes:87881958 (83.8 Mb)
Interrupt:5 Base Address:0x7000
or 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:16436 Metric:1
RX packets:72610 errors:0 dropped:0 overruns:0 frame:0
TX packets:72610 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:7969003 (7.5 Mb) TX bytes:7969003 (7.5 Mb)

To configure the IP, mask, and broadcast of a network card:

$ ifconfig eth0 10.0.0.1 netmask 255.255.0.0 broadcast 10.0.0.255

To lift a network interface:

$ ifconfig eth0 up

To view a particular network interface:

$ ifconfig eth0
eth0 Link Encap:Ethernet HWaddr 00:50:FC: 34:7 E:1E
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.0.0
inet6 addr: fe80: :250:fcff:fe 34:7 e1e/64 Scope:Link
UP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1
RX packets:37120678 errors:0 dropped:0 overruns:0 frame:0
TX packets:716794 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:100
RX bytes:3034722143 (2894.1 Mb) TX bytes:87881958 (83.8 Mb)
Interrupt:5 Base Address:0x7000

The ifconfig command can be used to verify IPv4 and IPv6 network addresses.