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:
$ ifconfigeth0 Link Encap:Ethernet HWaddr 00:50:FC: 34:7 E:1Einet addr:200.150.34.188 Bcast:255.255.255.255 Mask:255.255.248.0inet6 addr: fe80: :250:fcff:fe 34:7 e1e/64 Scope:LinkUP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1RX packets:37120678 errors:0 dropped:0 overruns:0 frame:0TX packets:716794 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:100RX bytes:3034722143 (2894.1 Mb) TX bytes:87881958 (83.8 Mb)Interrupt:5 Base Address:0x7000or Link Encap:Local Loopbackinet addr:127.0.0.1 Mask:255.0.0.0inet6 addr: ::1/128 Scope:HostUP LOOPBACK RUNNING MTU:16436 Metric:1RX packets:72610 errors:0 dropped:0 overruns:0 frame:0TX packets:72610 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:0RX 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 eth0eth0 Link Encap:Ethernet HWaddr 00:50:FC: 34:7 E:1Einet addr:10.0.0.1 Bcast:10.0.0.255 Mask:255.255.0.0inet6 addr: fe80: :250:fcff:fe 34:7 e1e/64 Scope:LinkUP BROADCAST NOTRAILERS RUNNING MULTICAST MTU:1500 Metric:1RX packets:37120678 errors:0 dropped:0 overruns:0 frame:0TX packets:716794 errors:0 dropped:0 overruns:0 carrier:0collisions:0 txqueuelen:100RX 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.