Open herrdu opened 3 years ago
ifconfig in short “interface configuration” utility for system/network administration in Unix/Linux operating systems to configure, manage and query network interface parameters via command-line interface or in a system configuration scripts.
[ You might also like: 22 Linux Networking Commands for Sysadmin ]
The “ifconfig” command is used for displaying current network configuration information, setting up an ip address, netmask, or broadcast address to a network interface, creating an alias for the network interface, setting up hardware address, and enable or disable network interfaces.
Ifconfig Command Examples 15 Useful ifconfig Commands This article covers “15 Useful “ifconfig” Commands” with their practical examples, which might be very helpful to you in managing and configuring network interfaces in Linux systems.
Update: The networking command ifconfig is deprecated and replaced by the ip command (Learn 10 Examples of IP Command) in most Linux distributions.
[ You might also like: ifconfig vs ip: What’s Difference and Comparing Network Configuration ]
[root@tecmint ~]# ifconfig
eth0 Link encap:Ethernet HWaddr 00:0B:CD:1C:18:5A inet addr:172.16.25.126 Bcast:172.16.25.63 Mask:255.255.255.224 inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2341604 errors:0 dropped:0 overruns:0 frame:0 TX packets:2217673 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:293460932 (279.8 MiB) TX bytes:1042006549 (993.7 MiB) Interrupt:185 Memory:f7fe0000-f7ff0000
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:16436 Metric:1 RX packets:5019066 errors:0 dropped:0 overruns:0 frame:0 TX packets:5019066 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2174522634 (2.0 GiB) TX bytes:2174522634 (2.0 GiB)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:10.1.1.1 P-t-P:10.1.1.2 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[root@tecmint ~]# ifconfig -a
eth0 Link encap:Ethernet HWaddr 00:0B:CD:1C:18:5A inet addr:172.16.25.126 Bcast:172.16.25.63 Mask:255.255.255.224 inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2344927 errors:0 dropped:0 overruns:0 frame:0 TX packets:2220777 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:293839516 (280.2 MiB) TX bytes:1043722206 (995.3 MiB) Interrupt:185 Memory:f7fe0000-f7ff0000
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:16436 Metric:1 RX packets:5022927 errors:0 dropped:0 overruns:0 frame:0 TX packets:5022927 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:2175739488 (2.0 GiB) TX bytes:2175739488 (2.0 GiB)
sit0 Link encap:IPv6-in-IPv4 NOARP MTU:1480 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:0 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
tun0 Link encap:UNSPEC HWaddr 00-00-00-00-00-00-00-00-00-00-00-00-00-00-00-00 inet addr:10.1.1.1 P-t-P:10.1.1.2 Mask:255.255.255.255 UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1 RX packets:0 errors:0 dropped:0 overruns:0 frame:0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
[root@tecmint ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 00:0B:CD:1C:18:5A inet addr:172.16.25.126 Bcast:172.16.25.63 Mask:255.255.255.224 inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Link UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:2345583 errors:0 dropped:0 overruns:0 frame:0 TX packets:2221421 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:293912265 (280.2 MiB) TX bytes:1044100408 (995.7 MiB) Interrupt:185 Memory:f7fe0000-f7ff0000
[root@tecmint ~]# ifconfig eth0 up OR [root@tecmint ~]# ifup eth0
[root@tecmint ~]# ifconfig eth0 down OR [root@tecmint ~]# ifdown eth0
[root@tecmint ~]# ifconfig eth0 172.16.25.125 [ You might also like: How to Configure IP Network with ‘nmtui’ Tool ]
[root@tecmint ~]# ifconfig eth0 netmask 255.255.255.224
[root@tecmint ~]# ifconfig eth0 broadcast 172.16.25.63
[root@tecmint ~]# ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63
For example, “ifconfig eth0 mtu 1000” will set the maximum transmission unit to a given set (i.e. 1000). Not all network interfaces support MTU settings.
[root@tecmint ~]# ifconfig eth0 mtu 1000
Today’s network tools use the promiscuous mode to capture and analyze the packets that flow through the network interface. To set the promiscuous mode, use the following command.
[root@tecmint ~]# ifconfig eth0 promisc
[root@tecmint ~]# ifconfig eth0 -promisc
[root@tecmint ~]# ifconfig eth0:0 172.16.25.127 Next, verify the newly created alias network interface address, by using the “ifconfig eth0:0” command.
[root@tecmint ~]# ifconfig eth0:0
eth0:0 Link encap:Ethernet HWaddr 00:01:6C:99:14:68 inet addr:172.16.25.123 Bcast:172.16.25.63 Mask:255.255.255.240 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 Interrupt:17
[root@tecmint ~]# ifconfig eth0:0 down
[root@tecmint ~]# ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF These are the most useful commands for configuring network interfaces in Linux, for more information and usage of the ifconfig command use the manpages like “man ifconfig” at the terminal. Check out some other networking utilities below.
Other Networking Utilities nmcli – a command-line client that is used to control NetworkManager and report network information. Tcmpdump – is a command-line packet capture and analyzer tool for monitoring network traffic. Netstat – is an open-source command-line network monitoring tool that monitors incoming and outgoing network packets traffic. ss (socket statistics) – a tool that prints network socket-related information on a Linux system. Wireshark – is an open-source network protocol analyzer that is used to troubleshoot network-related issues. Munin – is a web-based network and system monitoring application that is used to display results in graphs using rrdtool. Cacti – is a complete web-based monitoring and graphing application for network monitoring. To get more information and options for any of the above tools, see the man pages by entering “man toolname” at the command prompt. For example, to get the information for the “netstat” tool, use the command “man netstat“.
https://www.tecmint.com/ifconfig-command-examples/