ifconfig on Linux: Configure Network Interfaces (Legacy)
The ifconfig command in Linux creates and configures network interfaces and their parameters. This operation is usually done during the system boot process. If no parameters are passed, it displays the active interfaces' configurations.
The ifconfig command is no longer used in distributions, the ip command is preferred.
The ifconfig parameters can be:
- interface: It's the network interface name. Usually it's the driver name 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 Resolution Protocol);
- [-]promisc: Enables or disables promiscuous mode on an interface. In this mode it will receive all network packets;
- mtu num: Sets the MTU (Maximum Transfer Unit) to num on an interface;
- address: Sets an IP address for the interface;
- netmask mask: Sets a specific subnet mask for the interface.
Examples:
$ ifconfig
eth0 Link encap:Ethernet HWaddr 00:50:FC:34:7E:1E
inet addr:200.150.34.188 Bcast:255.255.255.255 Mask:255.255.248.0
inet6 addr: fe80::250:fcff:fe34:7e1e/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
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: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 address, netmask, and broadcast of a network card:
$ ifconfig eth0 10.0.0.1 netmask 255.255.0.0 broadcast 10.0.0.255
To bring up a network interface:
$ ifconfig eth0 up
To view a specific network interface:
$ ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:50:FC:34:7E:1E
inet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.0.0
inet6 addr: fe80::250:fcff:fe34:7e1e/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 check IPv4 and IPv6 network addresses.
Learn much more about Linux in our online course. You can enroll here. If you already have an account, or want to create one, just log in or create your user here.
Liked it? Share
That was just one piece. The course teaches the whole path — from your first command to exam day.