ifconfig briefly “interface configuration” utility for system/community administration in Unix/Linux working programs to configure, handle, and question community interface parameters by way of command-line interface or in a system configuration scripts.
The “ifconfig” command is used for displaying present community configuration data, establishing an ip tackle, netmask, or broadcast tackle to a community interface, creating an alias for the community interface, establishing {hardware} tackle, and enabling or disabling community interfaces.
This text covers 15 helpful “ifconfig” instructions with their sensible examples, which is likely to be very useful to you in managing and configuring community interfaces in Linux programs.
1. Listing Community Interfaces in Linux
The “ifconfig” command with no arguments will show all of the energetic community interface configuration particulars that features their assigned IP addresses, netmasks, and different related data.
$ ifconfig
Pattern Output:
eth0 Hyperlink encap:Ethernet HWaddr 00:0B:CD:1C:18:5A
inet addr:172.16.25.126 Bcast:172.16.25.63 Masks:255.255.255.224
inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Hyperlink
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2341604 errors:0 dropped:0 overruns:0 body:0
TX packets:2217673 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:1000
RX bytes:293460932 (279.8 MiB) TX bytes:1042006549 (993.7 MiB)
Interrupt:185 Reminiscence:f7fe0000-f7ff0000
lo Hyperlink encap:Native Loopback
inet addr:127.0.0.1 Masks: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 body:0
TX packets:5019066 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:0
RX bytes:2174522634 (2.0 GiB) TX bytes:2174522634 (2.0 GiB)
tun0 Hyperlink 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 Masks:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 body:0
TX packets:0 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
2. Show Data on All Community Interfaces
The next ifconfig command with the -a argument will show data on all energetic or inactive community interfaces on the server. It shows the outcomes for eth0, lo, sit0, and tun0.
# ifconfig -a
eth0 Hyperlink encap:Ethernet HWaddr 00:0B:CD:1C:18:5A
inet addr:172.16.25.126 Bcast:172.16.25.63 Masks:255.255.255.224
inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Hyperlink
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2344927 errors:0 dropped:0 overruns:0 body:0
TX packets:2220777 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:1000
RX bytes:293839516 (280.2 MiB) TX bytes:1043722206 (995.3 MiB)
Interrupt:185 Reminiscence:f7fe0000-f7ff0000
lo Hyperlink encap:Native Loopback
inet addr:127.0.0.1 Masks: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 body:0
TX packets:5022927 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:0
RX bytes:2175739488 (2.0 GiB) TX bytes:2175739488 (2.0 GiB)
sit0 Hyperlink encap:IPv6-in-IPv4
NOARP MTU:1480 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 body:0
TX packets:0 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:0
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
tun0 Hyperlink 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 Masks:255.255.255.255
UP POINTOPOINT RUNNING NOARP MULTICAST MTU:1500 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 body:0
TX packets:0 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:100
RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
3. View Community Settings of Particular Interface
Utilizing interface title (eth0) as an argument with the “ifconfig” command will show particulars of the precise community interface.
# ifconfig eth0
eth0 Hyperlink encap:Ethernet HWaddr 00:0B:CD:1C:18:5A
inet addr:172.16.25.126 Bcast:172.16.25.63 Masks:255.255.255.224
inet6 addr: fe80::20b:cdff:fe1c:185a/64 Scope:Hyperlink
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:2345583 errors:0 dropped:0 overruns:0 body:0
TX packets:2221421 errors:0 dropped:0 overruns:0 provider:0
collisions:0 txqueuelen:1000
RX bytes:293912265 (280.2 MiB) TX bytes:1044100408 (995.7 MiB)
Interrupt:185 Reminiscence:f7fe0000-f7ff0000
4. How you can Allow a Community Interface
The “up” or “ifup” flag with interface title (eth0) prompts a community interface if it’s not inactive state and permits to ship and obtain data.
For instance, “ifconfig eth0 up” or “ifup eth0” will activate the eth0 interface.
# ifconfig eth0 up
OR
# ifup eth0
5. How you can Disable a Community Interface
The “down” or “ifdown” flag with interface title (eth0) deactivates the required community interface. For instance, the “ifconfig eth0 down” or “ifdown eth0” command deactivates the eth0 interface whether it is in an inactive state.
# ifconfig eth0 down
OR
# ifdown eth0
6. How you can Assign an IP Tackle to Community Interface
To assign an IP tackle to a particular interface, use the next command with an interface title (eth0) and ip tackle that you simply wish to set. For instance, “ifconfig eth0 172.16.25.125” will set the IP tackle to interface eth0.
# ifconfig eth0 172.16.25.125
7. How you can Assign a Netmask to Community Interface
Utilizing the “ifconfig” command with the “netmask” argument and interface title as (eth0) lets you outline a netmask to a given interface. For instance, “ifconfig eth0 netmask 255.255.255.224” will set the community masks to a given interface eth0.
[[email protected] ~]# ifconfig eth0 netmask 255.255.255.224
8. How you can Assign a Broadcast to Community Interface
Utilizing the “broadcast” argument with an interface title will set the published tackle for the given interface. For instance, the “ifconfig eth0 broadcast 172.16.25.63” command units the published tackle to an interface eth0.
# ifconfig eth0 broadcast 172.16.25.63
9. How you can Assign an IP, Netmask, and Broadcast to Community Interface
To assign an IP tackle, Netmask tackle, and Broadcast tackle suddenly utilizing the “ifconfig” command with all arguments as given under.
# ifconfig eth0 172.16.25.125 netmask 255.255.255.224 broadcast 172.16.25.63
10. How you can Change MTU for a Community Interface
The “mtu” argument units the utmost transmission unit to an interface. The MTU lets you set the restrict dimension of packets which are transmitted on an interface. The MTU is ready to deal with a most variety of octets to an interface in a single single transaction.
For instance, “ifconfig eth0 mtu 1000” will set the utmost transmission unit to a given set (i.e. 1000). Not all community interfaces help MTU settings.
# ifconfig eth0 mtu 1000
11. How you can Allow Promiscuous Mode
What occurs in regular mode, is when a packet is obtained by a community card, it verifies that it belongs to itself. If not, it drops the packet usually, however within the promiscuous mode is used to just accept all of the packets that stream by the community card.
Right now’s community instruments use the promiscuous mode to seize and analyze the packets that stream by the community interface. To set the promiscuous mode, use the next command.
# ifconfig eth0 promisc
12. How you can Disable Promiscuous Mode
To disable promiscuous mode, use the “-promisc” change that drops again the community interface to regular mode.
# ifconfig eth0 -promisc
13. How you can Add New Alias to Community Interface
The ifconfig utility lets you configure extra community interfaces utilizing the alias function. So as to add the alias community interface of eth0, use the next command. Please word that the alias community tackle is in the identical subnet masks. For instance, in case your eth0 community ip tackle is 172.16.25.125, then the alias ip tackle should be 172.16.25.127.
# ifconfig eth0:0 172.16.25.127
Subsequent, confirm the newly created alias community interface tackle, by utilizing the “ifconfig eth0:0” command.
# ifconfig eth0:0
eth0:0 Hyperlink encap:Ethernet HWaddr 00:01:6C:99:14:68
inet addr:172.16.25.123 Bcast:172.16.25.63 Masks:255.255.255.240
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
Interrupt:17
14. How you can Take away Alias to Community Interface
In the event you not required an alias community interface otherwise you incorrectly configured it, you possibly can take away it by utilizing the next command.
# ifconfig eth0:0 down
15. How you can Change the MAC tackle of Community Interface
To alter the MAC (Media Entry Management) tackle of an eth0 community interface, use the next command with the argument “hw ether“. For instance, see under.
# ifconfig eth0 hw ether AA:BB:CC:DD:EE:FF
These are probably the most helpful instructions for configuring community interfaces in Linux, for extra data and utilization of the ifconfig command use the manpages like “man ifconfig” on the terminal. Take a look at another networking utilities under.
Different Networking Utilities
nmcli – a command-line shopper that’s used to manage NetworkManager and report community data.
Tcmpdump – is a command-line packet seize and analyzer software for monitoring community site visitors.
Netstat – is an open-source command-line community monitoring software that screens incoming and outgoing community packet site visitors.
ss (socket statistics) – a software that prints community socket-related data on a Linux system.
Wireshark – is an open-source community protocol analyzer that’s used to troubleshoot network-related points.
Munin – is a web-based community and system monitoring software that’s used to show ends in graphs utilizing rrdtool.
Cacti – is a whole web-based monitoring and graphing software for community monitoring.
To get extra data and choices for any of the above instruments, see the person pages by getting into “man toolname” on the command immediate. For instance, to get the knowledge for the “netstat” software, use the command “man netstat“.