ifconfig command in Linux with Examples - GeeksforGeeks

18 May, 2020
ifconfig(interface configuration) command is used to configure the kernel-resident network interfaces. It is used at the boot time to set up the interfaces as necessary. After that, it is usually used when needed during debugging or when you need system tuning. Also, this command is used to assign the IP address and netmask to an interface or to enable or disable a given interface.
Syntax:
ifconfig [...OPTIONS] [INTERFACE]

Newer versions of some Linux distributions don’t have ifconfig command pre-installed. So, in case, there is an error “ifconfig: command not found”, Then execute the following command to install ifconfig.
For Debian, Ubuntu, and related Linux distributions.
sudo apt-get install net-tools

For CentOS or RPM(RedHat Package Manager) based Linux
yum install net-tools

This will install ifconfig along with some other networking commands like arp, route, ipmaddr.
Options:
-a : This option is used to display all the interfaces available, even if they are down.Syntax:ifconfig -aOutput:
Syntax:
ifconfig -a
Output:
-s : Display a short list, instead of details.Syntax:ifconfig -sOutput:
Syntax:
ifconfig -s
Output:
-v : Run the command in verbose mode – log more details about execution.Syntax:ifconfig -vOutput:
Syntax:
ifconfig -v
Output:
up : This option is used to activate the driver for the given interface.Syntax:ifconfig interface up
Syntax:
ifconfig interface up
down : This option is used to deactivate the driver for the given interface.Syntax:ifconfig interface down
Syntax:
ifconfig interface down
add addr/prefixlen : This option is used to add an IPv6 address to an interface.Syntax:ifconfig interface add addr/prefixlen
Syntax:
ifconfig interface add addr/prefixlen
del addr/prefixlen : This option is used to remove an IPv6 address to an interface.Syntax:ifconfig interface del addr/prefixlen
Syntax:
ifconfig interface del addr/prefixlen
[-]arp : This option is used to enable/disable the use of ARP protocol on an interface.Syntax:ifconfig interface [-]arp
Syntax:
ifconfig interface [-]arp
[-]promisc : This option is used to enable/disable the promiscuous mode on an interface. If it is selected, all the packets on the network will be received by the interface.Syntax:ifconfig interface [-]promisc
Syntax:
ifconfig interface [-]promisc
[-]allmulti : This option is used to enable/disable all-multicast mode for an interface. If it is selected, all the multicast packets will be received by the interface.Syntax:ifconfig interface [-]allmulti
Syntax:
ifconfig interface [-]allmulti
mtu N : The user uses this parameter to set the Maximum Transfer Unit(MTU).Syntax:ifconfig interface [-]allmulti
Syntax:
ifconfig interface [-]allmulti
–help : Display help related to ifconfig command.Syntax:ifconfig --helpOutput:
Syntax:
ifconfig --help
Output:
manav014
linux-command
Linux-networking-commands
Picked
Linux-Unix
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
ZIP command in Linux with examples
TCP Server-Client implementation in C
SORT command in Linux/Unix with examples
tar command in Linux with examples
curl command in Linux with Examples
Conditional Statements | Shell Script
diff command in Linux with examples
Tail command in Linux with examples
UDP Server-Client implementation in C
echo command in Linux with Examples