- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Ifconfig Command in Linux
Introduction
ifconfig command is an important tool used in Linux operating system for network administration. It is a command line utility that is used to configure network interfaces and display network interface parameters. In this article, we will discuss ifconfig command in detail, including its syntax, options, and usage.
Syntax of ifconfig Command
The syntax of ifconfig command is as follows −
ifconfig [interface] [options]
In above syntax, "interface" parameter specifies network interface for which you want to configure or display information. If you do not specify any interface, command will display information for all available interfaces.
The "options" parameter specifies action that you want to perform on specified interface. There are several options available for ifconfig command that can be used to configure or display network interface parameters. Let's discuss some of commonly used options below.
Options of ifconfig Command
up/down "up" option is used to bring up a network interface, while "down" option is used to bring it down. For example, following command will bring up interface named "eth0" −
ifconfig eth0 up
inet addr "inet addr" option is used to set IP address for a network interface. For example, following command will set IP address of interface named "eth0" to 192.168.1.10 −
ifconfig eth0 inet addr 192.168.1.10
netmask "netmask" option is used to set subnet mask for a network interface. For example, following command will set subnet mask of interface named "eth0" to 255.255.255.0 −
ifconfig eth0 netmask 255.255.255.0
broadcast "broadcast" option is used to set broadcast address for a network interface. For example, following command will set broadcast address of interface named "eth0" to 192.168.1.255 −
ifconfig eth0 broadcast 192.168.1.255
hw "hw" option is used to set MAC address for a network interface. For example, following command will set MAC address of interface named "eth0" to 00:11:22:33:44:55 −
ifconfig eth0 hw ether 00:11:22:33:44:55
mtu "mtu" option is used to set maximum transmission unit (MTU) for a network interface. For example, following command will set MTU of interface named "eth0" to 1500 −
ifconfig eth0 mtu 1500
promisc "promisc" option is used to enable or disable promiscuous mode for a network interface. In promiscuous mode, network interface will capture all packets on network, even those not intended for it. For example, following command will enable promiscuous mode for interface named "eth0" −
ifconfig eth0 promisc
Examples of ifconfig Command
Displaying Information for All Interfaces To display information for all available network interfaces, simply type ifconfig command without any options or parameters −
ifconfig
This will display information for all available interfaces, including their IP addresses, netmasks, and MAC addresses.
Setting IP Address for an Interface To set IP address for a network interface, use "inet addr" option followed by IP address. For example, following command will set IP address of interface named "eth0" to 192.168.1.10 −
ifconfig eth0 inet addr 192.168.1.10
Bringing up or Down an Interface To bring up a network interface, use "up" option followed by interface name. For example, following command will bring up interface named "eth0" −
ifconfig eth0 up
To bring down a network interface, use "down" option followed by interface name. For example, following command will bring down interface named "eth0" −
ifconfig eth0 down
Setting Promiscuous Mode To enable promiscuous mode for a network interface, use "promisc" option followed by interface name. For example, following command will enable promiscuous mode for interface named "eth0" −
ifconfig eth0 promisc
To disable promiscuous mode for a network interface, use "-promisc" option followed by interface name. For example, following command will disable promiscuous mode for interface named "eth0" −
ifconfig eth0 -promisc
Setting MTU To set maximum transmission unit (MTU) for a network interface, use "mtu" option followed by interface name and desired MTU value. For example, following command will set MTU of interface named "eth0" to 1500 −
ifconfig eth0 mtu 1500
Displaying Information for a Specific Interface To display information for a specific network interface, simply type ifconfig command followed by interface name. For example, following command will display information for interface named "eth0" −
ifconfig eth0
This will display information for interface, including its IP address, netmask, and MAC address.
Conclusion
ifconfig command is an essential tool for network administration in Linux operating system. It is used to configure network interfaces and display their parameters. In this article, we discussed syntax, options, and examples of ifconfig command. We also covered some of commonly used options for ifconfig command, such as setting IP address, bringing up or down an interface, enabling promiscuous mode, setting MTU, and displaying information for a specific interface. By using ifconfig command, network administrators can easily configure and manage network interfaces on Linux systems.