{"id":5110,"date":"2018-06-25T16:53:49","date_gmt":"2018-06-25T12:53:49","guid":{"rendered":"https:\/\/www.howtoforge.com\/linux-ifconfig-command\/"},"modified":"2018-06-25T16:53:49","modified_gmt":"2018-06-25T12:53:49","slug":"linux-ifconfig-command-tutorial-for-beginners-7-examples","status":"publish","type":"post","link":"https:\/\/afaghhosting.net\/blog\/linux-ifconfig-command-tutorial-for-beginners-7-examples\/","title":{"rendered":"Linux ifconfig Command Tutorial for Beginners (7 Examples)"},"content":{"rendered":"<p>Network management work includes a lot of stuff, and precisely for this reason, there are several Linux command line utilities that help you with different kind of network-related tasks. In this tutorial, we will discuss one such utility dubbed <strong>ifconfig<\/strong>. But before we start with it, it&#8217;s worth mentioning that all examples discussed in this article have been tested on an Ubuntu 16.04 LTS machine.<\/p>\n<h2 id=\"linux-ifconfig-command\">Linux ifconfig command<\/h2>\n<p>The ifconfig command gives you the ability to configure network interfaces. Of course, you can also fetch information related to network interfaces with this tool. Following is its syntax:<\/p>\n<p class=\"command\">ifconfig [-v] [-a] [-s] [interface]<br \/>ifconfig [-v] interface [aftype] options | address &#8230;<\/p>\n<p>And here&#8217;s how the tool&#8217;s man page explains it:<\/p>\n<pre readability=\"13\"> Ifconfig\u00a0 is\u00a0 used to configure the kernel-resident network interfaces.<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 It is used at boot time to set up interfaces as necessary.\u00a0 After that,<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 it\u00a0 is\u00a0 usually\u00a0 only\u00a0 needed\u00a0 when\u00a0 debugging or when system tuning is<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 needed.<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 If no arguments are given, ifconfig displays the\u00a0 status\u00a0 of\u00a0 the\u00a0 cur?<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 rently\u00a0 active interfaces.\u00a0 If a single interface argument is given, it<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 displays the status of the given interface only; if a single\u00a0 -a\u00a0 argu?<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 ment\u00a0 is\u00a0 given,\u00a0 it\u00a0 displays the status of all interfaces, even those<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 that are down.\u00a0 Otherwise, it configures an interface.<\/p><\/pre>\n<p>Following are some Q&amp;A-styled examples that should give you a good idea on how the ifconfig command works.<\/p>\n<h2 id=\"q-how-to-use-the-ifconfig-command\">Q1. How to use the ifconfig command?<\/h2>\n<p>Basic usage is fairly simple &#8211; just execute the &#8216;ifconfig&#8217; command sans any options.<\/p>\n<p class=\"command\">ifconfig<\/p>\n<p>In output, you&#8217;ll see information related to all active interfaces. For example, in my case, the following output was produced.<\/p>\n<p><a class=\"fancybox\" id=\"img-ifconfig-basic\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/ifconfig-basic.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-ifconfig-command-tutorial-for-beginners-7-examples.png\" alt=\"How to use ifconfig command\" width=\"500\" height=\"328\" title=\"\"><\/a><\/p>\n<p>Note that in case you want the command to display all interfaces (including those currently down), use the -a command line option.<\/p>\n<h2 id=\"q-how-to-make-ifconfig-display-compact-output\">Q2. How to make ifconfig display compact output?<\/h2>\n<p>For a short list output, use the -s command line option.<\/p>\n<p class=\"command\">ifconfig -s<\/p>\n<p>Here&#8217;s a sample output:<\/p>\n<p><a class=\"fancybox\" id=\"img-ifconfig-s\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/ifconfig-s.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-ifconfig-command-tutorial-for-beginners-7-examples-1.png\" alt=\"How to make ifconfig display compact output\" width=\"500\" height=\"94\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-make-ifconfig-display-info-about-anbspspecific-interface\">Q3. How to make ifconfig display info about a\u00a0specific interface?<\/h2>\n<p>This you can do by\u00a0specifying the name of the interface as an argument to the ifconfig command.<\/p>\n<p class=\"command\">ifconfig [interface-name]<\/p>\n<p>For example:<\/p>\n<p><a class=\"fancybox\" id=\"img-ifconfig-interface\" href=\"https:\/\/www.howtoforge.com\/images\/command-tutorial\/big\/ifconfig-interface.png\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-ifconfig-command-tutorial-for-beginners-7-examples-2.png\" alt=\"How to make ifconfig display info about specific interface\" width=\"500\" height=\"113\" title=\"\"><\/a><\/p>\n<h2 id=\"q-how-to-disable-or-enable-a-network-interface-using-ifconfig\">Q4. How to disable or enable a network interface using ifconfig?<\/h2>\n<p>To do this, just specify the &#8216;down&#8217; or &#8216;up&#8217; flags. For example, to disable an interface dubbed eth0, use the ifconfig command in the following way:<\/p>\n<p class=\"command\">ifconfig eth0 down<\/p>\n<p>Similarly, to enable, use the following command:<\/p>\n<p class=\"command\">ifconfig eth0 up<\/p>\n<h2 id=\"q-how-to-change-a-network-mtu-using-ifconfig\">Q5. How to change a network MTU using ifconfig?<\/h2>\n<p>This you can do by using the &#8216;mtu&#8217; flag along with the new mtu value.<\/p>\n<p class=\"command\">ifconfig [interface-name] mtu [mtu-value]<\/p>\n<p>For example:<\/p>\n<p class=\"command\">ifconfig eth0 mtu 900<\/p>\n<p>PS: For those who aren&#8217;t aware what MTU is, head <a href=\"https:\/\/en.wikipedia.org\/wiki\/Maximum_transmission_unit\" target=\"_blank\" rel=\"noopener noreferrer\">here<\/a>.<\/p>\n<h2 id=\"q-how-to-enable-promiscuous-mode-on-an-interface\">Q6. How to enable promiscuous mode on an interface?<\/h2>\n<p>Promiscuous mode allows a network to receive all packets on the network. If that&#8217;s your requirement, you can enable this mode using the &#8216;promisc&#8217; flag.<\/p>\n<p>For example:<\/p>\n<p class=\"command\">ifconfig eth0 promisc<\/p>\n<p>Note that you can disable the promiscuous mode in the following way:<\/p>\n<p class=\"command\">ifconfig eth0 -promisc<\/p>\n<h2 id=\"q-how-to-change-hardware-address-of-network-interface\">Q7. How to change hardware address of network interface?<\/h2>\n<p>The ifconfig command also allows you to change the MAC address corresponding to a network interface. This you can do in the following way:<\/p>\n<p class=\"command\">ifconfig [network-name] hw [class] [hardware-address]<\/p>\n<p>For example:<\/p>\n<p class=\"command\">ifconfig eth0 hw ether 70:4d:7b:70:d2:3e<\/p>\n<p>Here&#8217;s how the man page explains this option:<\/p>\n<pre> Set the hardware address of this interface, if the device driver<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 supports\u00a0 this\u00a0 operation.\u00a0 The keyword must be followed by the<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 name of the hardware class and the printable ASCII equivalent of<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 the\u00a0 hardware\u00a0 address.\u00a0\u00a0 Hardware\u00a0 classes\u00a0 currently supported<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 include ether (Ethernet), ax25 (AMPR AX.25), ARCnet\u00a0 and\u00a0 netrom<br\/>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 (AMPR NET\/ROM).<\/pre>\n<h2 id=\"conclusion\">Conclusion<\/h2>\n<p>So you can see, the ifconfig command lets you do a lot of things related to network interfaces. While we have discussed quite a few command line options here, there are many others as well. Once you are done practicing the ones we&#8217;ve discussed here, head to the tool&#8217;s\u00a0<a href=\"https:\/\/linux.die.net\/man\/8\/ifconfig\" target=\"_blank\" rel=\"noopener noreferrer\">man page<\/a> to learn more.<\/p>\n<div>\n<p><b>Share this page:<\/b><\/p>\n<p>\n<a href=\"https:\/\/www.facebook.com\/sharer.php?u=https%3A%2F%2Fwww.howtoforge.com%2Flinux-ifconfig-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-ifconfig-command-tutorial-for-beginners-7-examples-3.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/intent\/tweet?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-ifconfig-command%2F&amp;text=Linux+ifconfig+Command+Tutorial+for+Beginners+%287+Examples%29&amp;via=howtoforgecom&amp;related=howtoforgecom\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-ifconfig-command-tutorial-for-beginners-7-examples-4.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/twitter.com\/howtoforgecom\/\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-ifconfig-command-tutorial-for-beginners-7-examples-5.png\" height=\"20\" alt=\"\" title=\"\"><\/a><br \/>\n<a href=\"https:\/\/plus.google.com\/share?url=https%3A%2F%2Fwww.howtoforge.com%2Flinux-ifconfig-command%2F\" target=\"_blank\" rel=\"nofollow noopener noreferrer\"><img decoding=\"async\" src=\"https:\/\/afaghhosting.net\/blog\/wp-content\/uploads\/2018\/06\/linux-ifconfig-command-tutorial-for-beginners-7-examples-6.png\" height=\"20\" alt=\"\" title=\"\"><\/a>\n<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>Network management work includes a lot of stuff, and precisely for this reason, there are several Linux command line utilities that help you with different kind of network-related tasks. In this tutorial, we will discuss one such utility dubbed ifconfig. But before we start with it, it&#8217;s worth mentioning that all examples discussed in this [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[36],"tags":[],"class_list":["post-5110","post","type-post","status-publish","format-standard","hentry","category-36"],"_links":{"self":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5110","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/comments?post=5110"}],"version-history":[{"count":0,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/posts\/5110\/revisions"}],"wp:attachment":[{"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/media?parent=5110"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/categories?post=5110"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/afaghhosting.net\/blog\/wp-json\/wp\/v2\/tags?post=5110"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}