ifconfig Linux command
The ifconfig
command in Linux is used to view and configure network interfaces, assign IP addresses, enable or disable network interfaces, and diagnose network connection issues. By running ifconfig
with appropriate options, users can display a list of all network interfaces on the system along with their current configurations. This command is essential for monitoring network traffic, troubleshooting connectivity problems, and configuring network settings. It is a versatile tool that provides valuable information about network interfaces and plays a crucial role in managing network connections effectively.
ifconfig Syntax:
Options:
Option | Description |
---|---|
-a | Display all interfaces |
-s | Display a short summary |
up | Activate the specified interface |
down | Deactivate the specified interface |
add | Add a new IPv4 address |
del | Delete an IPv4 address |
netmask | Specify the netmask for an interface |
Parameters:
Parameter | Description |
---|---|
interface | Specifies the network interface to configure |
options | Additional configuration options |
ifconfig bash Examples:
Display All Network Interfaces
Displays information about all network interfaces on the system.
Display Information for a Specific Interface
Displays detailed information about the network interface “eth0”.
Enable a Network Interface
Enables the network interface “eth0”.
Disable a Network Interface
Disables the network interface “eth0”.
Assign an IP Address to an Interface
Assigns the IP address “192.168.1.100” to the network interface “eth0”.
Change Netmask of an Interface
Changes the netmask of the network interface “eth0” to “255.255.255.0”.
How do I use ifconfig in Linux?
To use the ifconfig command in Linux, execute the following command:
How to display only IPv4 addresses using ifconfig?
To display only IPv4 addresses using ifconfig, use the following command:
How to bring up a network interface using ifconfig?
To bring up a network interface using ifconfig, run the following command:
How to assign an IP address to a network interface using ifconfig?
To assign an IP address to a network interface using ifconfig, use the following command:
How to set a default gateway using ifconfig?
To set a default gateway using ifconfig, execute the following command:
How to display detailed information about all network interfaces using ifconfig?
To display detailed information about all network interfaces using ifconfig, run the following command:
How to disable a network interface using ifconfig?
To disable a network interface using ifconfig, use the following command:
How to change the MAC address of a network interface using ifconfig?
To change the MAC address of a network interface using ifconfig, execute the following command:
Applications of the ifconfig command
- Configure network interfaces
- Display network interface information
- Enable or disable network interfaces
- Assign IP addresses to network interfaces
- View current network configuration
- Troubleshoot network connectivity issues