ifconfig

Introduction

ifconfig (short for interface configuration) is a command of UNIX and UNIX-like operating systems.

The modern alternative to ifconfig is ip

Syntax

ifconfig [interface]
ifconfig interface [aftype] options | address ...

Description

The ifconfig command is the counterpart of Windows IPconfig, with different key parameters and broader functionality.

It is used to assign a network address and to change the settings of the network adapter and IP protocol parameters.

It is used in most *nix systems at operating system boot time to configure network interfaces. After that it is usually used only for debugging, configuring or recovering a system.

Running man ifconfig (on FreeBSD) prints the full manual on the command's parameters.

If no arguments are given, ifconfig reports the state of the active interfaces. If a single interface argument is given, it reports the state of that interface only; if the single argument -a is given, it reports the state of all interfaces, even the disabled ones. Otherwise the command configures the given interface.

In modern Linux distributions the ifconfig utility is considered obsolete and has been replaced by iproute2; the main network interface configuration functions went to the ip utility from the iproute2 package. For Unix systems it has not lost its relevance.

Protocol family

If the first thing after the interface name is the name of a supported address family, that address family is used to decode and display all protocol addresses.

The currently supported address families are inet (TCP/IP, the default), inet6 (IPv6), ax25 (AMPR Packet Radio), ddp (Appletalk Phase 2), ipx (Novell IPX) and netrom (AMPR Packet Radio).

Options

OptionDescription
interface The interface name. Usually this is the driver name followed by the device number, for example eth0 for the first Ethernet interface.
up Marks the interface as up. This can be used to bring the interface up after ifconfig down. It happens automatically when the first address of the interface is set. If the interface was reset while previously marked as down, the hardware will be reinitialized.
down Marks the interface as down. When an interface is marked as down, the system does not try to transmit messages through that interface. Where possible, the interface is reset so that reception is disabled as well. This action does not automatically disable routes that use the interface.
arp Enables the use of the Address Resolution Protocol when mapping network-level addresses to link-level addresses (the default). This is currently implemented by mapping DARPA Internet addresses to 10 Mbit/s Ethernet addresses.
-arp Disables the use of the Address Resolution Protocol.
promisc Puts the interface into promiscuous mode. On a broadcast network this makes the interface receive all packets regardless of whether they were intended for this machine or not. It allows network traffic to be analysed using packet filters. This is usually a good technique for hunting down network problems that are otherwise hard to catch. The tcpdump utility is very useful here. On the other hand, it lets crackers study how passwords travel over the network and do other dark deeds. One defence against this type of attack: do not let other people's computers join the network. Another way: use secure authentication protocols such as Kerberos or SRA login. This option corresponds to the PROMISC flag.
-promisc Disables promiscuous mode.
allmulti Enables or disables all-multicast mode. In this mode all multicast packets on the network will be received by this interface.
-allmulti Disables all-multicast mode.
metric N Sets the routing cost of the interface to n instead of the default value 0. The routing metric is used by the routing protocol (see routed). Higher costs make a route less preferable; the costs are counted as additional hops on the way to the destination network or host.
mtu N This parameter sets the maximum transmission unit (MTU) for the interface. Usually there is no need to change this parameter, but in some cases lowering the MTU value helps subscribers with a very low signal level to work reliably. It can also be used to change the parameters of tunnel interfaces.
dstaddr addr Sets the remote IP address for a point-to-point link (for example, over PPP). This keyword is now considered obsolete; use the pointopoint keyword instead.
netmask addr Sets the IP network mask for this interface. By default the usual class A, B or C network mask is used (determined from the interface's IP address), but any value can be set.
add addr/prefixlen Adds an IPv6 address to the interface.
del addr/prefixlen Removes an IPv6 address from the interface.
tunnel aa.bb.cc.dd Creates a new SIT device (IPv6-in-IPv4), a tunnel to the given destination.
irq Sets the hardware interrupt used by this device. Not every device allows the IRQ value to be changed dynamically.
io_addr addr Sets the start address of the I/O region for this device.
mem_start addr Sets the start address of the shared memory region used by this device. Only a few devices need this.
media type Sets the physical port or media type used by the device. Not every device allows this parameter to be changed, and different devices may support different values. Typical type values are 10base2 (Ethernet coaxial cable), 10baseT (10 Mbit/s Ethernet twisted pair), AUI (external transceiver), etc. The special media type auto can be used to require the driver to detect the media type automatically. Not all drivers can do this.
bootproto [[static][dhcp]] Sets the way the IP address is obtained. (a static one that you specify, or a dynamic one obtained from a DHCP server) broadcast [addr] Sets the broadcast address. The broadcast address is usually derived from the network address by setting all bits of the machine part. Some IP implementations use a different scheme; this option helps to adapt to those strange environments. If a broadcast address has been set, ifconfig shows the BROADCAST flag. pointopoint [addr] This keyword enables the point-to-point mode of the interface, meaning that it provides a direct link between two machines that nobody else listens on. If an address argument is also given, it sets the protocol address of the other end of the link, like the obsolete dstaddr keyword. Otherwise, it sets or clears the IFF_POINTOPOINT flag for the interface. -pointopoint [addr] This keyword disables the point-to-point mode of the interface
hw class address Sets the hardware address of the given interface if the device driver supports it. After the hw keyword you must give the hardware class name and the hardware address in text form. The currently supported hardware classes are ether (Ethernet), ax25 (AMPR AX.25), ARCnet and netrom (AMPR NET/ROM).
multicast Sets the multicast support flag on the interface. Usually there is no need for this, since the driver sets this flag itself.
address The IP address assigned to the interface.
txqueuelen length Sets the transmit queue length for the device. This makes it possible to set smaller values for slower devices with long delays (modem lines, ISDN), so that a fast transfer of large amounts of data does not interfere too much with the data of interactive sessions such as telnet.

Examples

# ifconfig eth0 inet 192.168.10.15 netmask 255.255.255.0
# ifconfig eth0 up
# ifconfig

eth0 Link encap:Ethernet HWaddr 00:18:F3:BE:18:1E inet addr:192.168.10.15 Bcast:192.168.10.255 Mask:255.255.255.0 inet6 addr: fe80::218:f3ff:febe:181e/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:39456 errors:0 dropped:0 overruns:0 frame:0 TX packets:45730 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:25457904 (24.2 Mb) TX bytes:6540945 (6.2 Mb) Interrupt:20 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:16436 Metric:1 RX packets:182 errors:0 dropped:0 overruns:0 frame:0 TX packets:182 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:12812 (12.5 Kb) TX bytes:12812 (12.5 Kb) #

Installing

ifconfig is far from always installed by default.

For instructions on how to install ifconfig on .rpm Linux systems such as RedHat, Rocky or CentOS read the article

«Installing ifconfig in CentOS/RedHat»

For installation on Debian you can read the article

«Installing ifconfig in Debian Linux»

In short, on RedHat/CentOS/Rocky you need to run

yum install net-tools

And for Debian/Ubuntu

apt-get install net-tools

Article author: Andrei Olegovich

Banner image