ifconfig
ifconfig
ifconfig is a command-line utility used to configure network interfaces on Unix-like operating systems, including Linux. It is part of the net-tools package and is used to view and manage network interface configurations.
View All Network Interfaces:
ifconfigThis command displays information about all active network interfaces on the system.
View a Specific Network Interface:
ifconfig eth0Replace
eth0with the name of the network interface you want to view. This command displays detailed information about the specified interface.Bring Up a Network Interface:
ifconfig eth0 upThis command activates the
eth0network interface.Bring Down a Network Interface:
ifconfig eth0 downThis command deactivates the
eth0network interface.Assign an IP Address to a Network Interface:
ifconfig eth0 192.168.1.10 netmask 255.255.255.0This command assigns the IP address
192.168.1.10with a subnet mask of255.255.255.0to theeth0interface.Change the MTU of a Network Interface:
ifconfig eth0 mtu 1500This command sets the Maximum Transmission Unit (MTU) of the
eth0interface to1500bytes.Assign an IP Address with Broadcast and Netmask:
ifconfig eth0 192.168.1.10 netmask 255.255.255.0 broadcast 192.168.1.255This command assigns the IP address
192.168.1.10, subnet mask255.255.255.0, and broadcast address192.168.1.255to theeth0interface.Assign a MAC Address to a Network Interface:
ifconfig eth0 hw ether 00:1A:2B:3C:4D:5EThis command assigns the MAC address
00:1A:2B:3C:4D:5Eto theeth0interface.
Example of ifconfig Output
ifconfig OutputWhen you run ifconfig without any arguments, you might see output similar to this:
eth0 Link encap:Ethernet HWaddr 00:0c:29:36:bc:91
inet addr:192.168.1.10 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::20c:29ff:fe36:bc91/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:12345 errors:0 dropped:0 overruns:0 frame:0
TX packets:67890 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:1048576 (1.0 MB) TX bytes:524288 (512.0 KB)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
inet6 addr: ::1/128 Scope:Host
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:10 errors:0 dropped:0 overruns:0 frame:0
TX packets:10 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:820 (820.0 B) TX bytes:820 (820.0 B)Deprecation Notice
While ifconfig is still widely used, it is considered deprecated in favor of the ip command from the iproute2 package. The ip command provides more functionality and better capabilities for modern network configuration.
Basic Usage of ip Command
ip CommandView All Network Interfaces:
ip addrView a Specific Network Interface:
ip addr show dev eth0Bring Up a Network Interface:
ip link set eth0 upBring Down a Network Interface:
ip link set eth0 downAssign an IP Address to a Network Interface:
ip addr add 192.168.1.10/24 dev eth0Change the MTU of a Network Interface:
ip link set dev eth0 mtu 1500
Conclusion
ifconfig is a powerful and widely used tool for network configuration on Unix-like systems. Despite being deprecated in favor of the ip command, it remains an important utility, especially in legacy systems and for quick network interface management tasks. For modern and more complex networking tasks, transitioning to the ip command is recommended.
help
Usage:
ifconfig [-a] [-v] [-s] <interface> [[<AF>] <address>]
[add <address>[/<prefixlen>]]
[del <address>[/<prefixlen>]]
[[-]broadcast [<address>]] [[-]pointopoint [<address>]]
[netmask <address>] [dstaddr <address>] [tunnel <address>]
[outfill <NN>] [keepalive <NN>]
[hw <HW> <address>] [mtu <NN>]
[[-]trailers] [[-]arp] [[-]allmulti]
[multicast] [[-]promisc]
[mem_start <NN>] [io_addr <NN>] [irq <NN>] [media <type>]
[txqueuelen <NN>]
[[-]dynamic]
[up|down] ...
breakdown
-a, --all: This option displays all network interfaces.
-s, --statistics: This option displays statistics for the specified interface.
-v, --verbose: This option displays more information.Last updated