Ifconfig command, Linux
From RZWiki
A command line program available on most some Linux platforms; used to modify or display network interface configuration, status and statistics. This includes specifying IP and MAC address as well as enabling and disabling an interface.
Contents |
Usage Syntax
ifconfig interface [options] | (ip-address [netmask mask] | mac-address)
Common options include;
- up | down - enable or disable the interface
- metric - specify the interface metric (used by routing and other protocols)
- mtu - specify the interface MTU in bytes
- [-]arp - enable or disable ARP on the interface (enabled by default)
- [-]promisc - enable or disable promiscuous mode on the interface (disabled by default)
- hw ether mac-address - specify the interface MAC address
Usage Examples
ifconfig - display current interface configuration and status
ifconfig eth0 1.1.1.1 netmask 255.255.255.0 - configure interface eth0 with an IP address of 1.1.1.1 and subnet mask of 255.255.255.0
ifconfig eth0:0 2.2.2.1 netmask 255.255.255.0 - configure interface eth0 with an IP alias (or secondary) of eth0:0 using an IP address of 2.2.2.1 and subnet mask of 255.255.255.0 (use eth0:1 onwards for more)
ifconfig eth0 -arp - disable ARP on interface eth0
ifconfig eth0 mtu 1400 - configure interface eth0 with an MTU of 1400 bytes
Usage Notes
Only the first 9 characters of the interface name will be displayed. To display a list of complete interface names, useful when copying interface names for use with another command, use the ip link command instead.
When configuring interface aliases (i.e. eth0:1,) they will automatically inherit the up or down state of the associated physical interface.
Any changes made with the ifconfig command will not persist with a system restart or reboot. With most Linux platforms, the relevant interface configuration file ifcfg-interface-name found in the /etc/sysconfig/network-scripts/ directory must be modified accordingly (or created if it does not exist.) See the Interface Configuration Files, Linux article for information on file format and possible parameters.
The hw ether mac-address option allows for MAC address spoofing, commonly used to bypass MAC address filtering in wireless networks
In FreeBSD, the hw ether mac-address option syntax changes to link mac-address
Linux Usage Notes
With most Linux or Unix commands;
- Non root users may need to prefix commands with the sudo command, for example: sudo chmod 644 *
- Brief help can be displayed using the -h or --help parameter, for example: chmod --help
- A full command manual can be displayed using the man command followed by the command name, for example: man chmod
- Sometimes 'info' pages are used instead of or to provide more information than man pages; for example: info chmod
- Version information can normally be display using the -v, -V or --version parameter, for example: chmod --version. However, this paramater is also frequently used to display verbose output.
noinclude/noinclude
Typical Output
noinclude/noinclude
system-one#ifconfig
font color=blueVLAN_ONE Link encap:Ethernet HWaddr 10:01:D7:30:9A:85
inet addr:2.2.2.3 Bcast:2.2.2.255 Mask:255.255.255.0
inet6 addr: fe80::201:d7ff:ff30:9a35/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:15093612 errors:0 dropped:0 overruns:0 frame:0
TX packets:15105716 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:0
RX bytes:4161421228 (3968.6 Mb) TX bytes:1003225313 (956.7 Mb)
eth0 Link encap:Ethernet HWaddr 10:F0:81:64:24:34
inet addr:1.1.1.3 Bcast:1.1.1.255 Mask:255.255.255.0
inet6 addr: fe80::2f0:81ef:fe64:2734/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:1289028325 errors:0 dropped:0 overruns:0 frame:0
TX packets:1280072657 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:15810432 (15.0 Mb) TX bytes:4027063524 (3840.5 Mb)
Base address:0xc400 Memory:f2020000-f2040000/font
Related Commands
To simply enable and/or disable an interface, you may want to use the ifup and ifdown commands.
Use the mii-tool command to configure Ethernet interface speed, duplex and autonegotiation
Use the arp command to view the MAC address to IP address ARP table
Command Equivalents
The Cisco command equivalent is the show interface command
The F5 BigIP command equivalent is the bigpipe interface command
The Nokia IPSO closest command equivalent is the Show interfacemonitor command
Related Articles
For further information on MTU size parameters see the Ethernet IP MTU article
For further information on Linux files and their location, see the File Locations, Linux article
Information on other Linux commands
Information on F5 BigIP commands
Information on Cisco commands
Information on Vyatta commands
Information on Extreme commands
Information on Nortel commands
Information on Zebra commands
Information on Windows commands
Information on Secure Platform commands
Information on Blue Coat SGOS commands
Information on Nokia IPSO commands
(replacing the # with an @) |







