ifconfig in brief “interface configuration” utility for system/community administration in Unix/Linux working methods to configure, handle, and question community interface parameters through command-line interface or in a system configuration scripts.
The “ifconfig” command is used for displaying present community configuration data, organising an ip tackle, netmask, or broadcast tackle to a community interface, creating an alias for the community interface, organising {hardware} tackle, and enabling or disabling community interfaces.
This text covers 15 helpful “ifconfig” instructions with their sensible examples, which could be very useful to you in managing and configuring community interfaces in Linux methods.
1. Listing Community Interfaces in Linux
The “ifconfig” command with no arguments will show all of the lively 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 service: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 service: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 service:0 collisions:0 txqueuelen:100 RX bytes:0 (0.0 b) TX bytes:0 (0.0 b)
2. Show Info on All Community Interfaces
The next ifconfig command with the -a
argument will show data on all lively 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 service: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 service: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 service: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 service: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 identify (eth0) as an argument with the “ifconfig” command will show particulars of the particular 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 service:0 collisions:0 txqueuelen:1000 RX bytes:293912265 (280.2 MiB) TX bytes:1044100408 (995.7 MiB) Interrupt:185 Reminiscence:f7fe0000-f7ff0000
4. The right way to Allow a Community Interface
The “up” or “ifup” flag with interface identify (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. The right way to Disable a Community Interface
The “down” or “ifdown” flag with interface identify (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. The right way to Assign an IP Deal with to Community Interface
To assign an IP tackle to a particular interface, use the next command with an interface identify (eth0) and ip tackle that you simply need 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. The right way to Assign a Netmask to Community Interface
Utilizing the “ifconfig” command with the “netmask” argument and interface identify as (eth0) means that you can 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. The right way to Assign a Broadcast to Community Interface
Utilizing the “broadcast” argument with an interface identify will set the printed tackle for the given interface. For instance, the “ifconfig eth0 broadcast 172.16.25.63” command units the printed tackle to an interface eth0.
# ifconfig eth0 broadcast 172.16.25.63
9. The right way to Assign an IP, Netmask, and Broadcast to Community Interface
To assign an IP tackle, Netmask tackle, and Broadcast tackle unexpectedly 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. The right way to Change MTU for a Community Interface
The “mtu” argument units the utmost transmission unit to an interface. The MTU means that you can set the restrict measurement of packets which are transmitted on an interface. The MTU is in a position 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. The right way to Allow Promiscuous Mode
What occurs in regular mode, is when a packet is acquired 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 simply accept all of the packets that circulation by means of the community card.
As we speak’s community instruments use the promiscuous mode to seize and analyze the packets that circulation by means of the community interface. To set the promiscuous mode, use the next command.
# ifconfig eth0 promisc
12. The right way to Disable Promiscuous Mode
To disable promiscuous mode, use the “-promisc” change that drops again the community interface to regular mode.
# ifconfig eth0 -promisc
13. The right way to Add New Alias to Community Interface
The ifconfig utility means that you can configure further community interfaces utilizing the alias function. So as to add the alias community interface of eth0, use the next command. Please be aware 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 have to 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. The right way to Take away Alias to Community Interface
If you happen to now not required an alias community interface otherwise you incorrectly configured it, you may take away it by utilizing the next command.
# ifconfig eth0:0 down
15. The right way to 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. Try another networking utilities under.
Different Networking Utilities
- nmcli – a command-line shopper that’s used to regulate NetworkManager and report community data.
- Tcmpdump – is a command-line packet seize and analyzer instrument for monitoring community site visitors.
- Netstat – is an open-source command-line community monitoring instrument that displays incoming and outgoing community packet site visitors.
- ss (socket statistics) – a instrument 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 leads to graphs utilizing rrdtool.
- Cacti – is an entire 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 coming into “man toolname” on the command immediate. For instance, to get the knowledge for the “netstat” instrument, use the command “man netstat“.