{"id":1357,"date":"2016-06-13T17:15:27","date_gmt":"2016-06-13T14:15:27","guid":{"rendered":"http:\/\/www.systemcodegeeks.com\/?p=1357"},"modified":"2016-06-13T12:38:40","modified_gmt":"2016-06-13T09:38:40","slug":"linux-ifconfig-tutorial","status":"publish","type":"post","link":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/","title":{"rendered":"Linux IfConfig Tutorial"},"content":{"rendered":"<p>The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is <code>ifconfig<\/code> (contraction of <em>interface<\/em> and <em>configuration<\/em>), which allows to make almost any configuration in a network, as we will see in this tutorial.<\/p>\n<p>Basic knowledge about networking (what IP addresses are, their format, subnetting, etc.) is assumed in order to follow this tutorial.<\/p>\n<p>For this tutorial, Linux Mint 17.3 has been used.<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#section_1\">1. Show network interface information<\/a><\/dt>\n<dt><a href=\"#section_2\">2. Enabling and disabling interfaces<\/a><\/dt>\n<dt><a href=\"#section_3\">3. Changing IP addresses<\/a><\/dt>\n<dd>\n<dl>\n<dt><a href=\"#section_3_1\">3.1. IPv4<\/a><\/dt>\n<dt><a href=\"#section_3_2\">3.2. IPv6<\/a><\/dt>\n<dt><a href=\"#section_3_3\">3.3. Changing from static IP to DHCP<\/a><\/dt>\n<\/dl>\n<\/dd>\n<dt><a href=\"#section_4\">4. Using virtual IP addresses<\/a><\/dt>\n<dt><a href=\"#section_5\">5. Changing MTU<\/a><\/dt>\n<dd><a href=\"#section_5_1\">5.1. Finding best MTU size<\/a><\/dd>\n<dt><a href=\"#section_6\">6. Changing MAC address<\/a><\/dt>\n<dt><a href=\"#section_7\">7. Promiscuous mode<\/a><\/dt>\n<dt><a href=\"#section_8\">8. ARP mode<\/a><\/dt>\n<dt><a href=\"#section_9\">9. Broadcast and multicast modes<\/a><\/dt>\n<dt><a href=\"#section_10\">10. IP tunneling<\/a><\/dt>\n<dt><a href=\"#section_11\">11. Summary<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2 id=\"section_1\">1. Show network interface information<\/h2>\n<p>The most simple way to use <code>ifconfig<\/code> is typing the command in the terminal, with no options or arguments:<\/p>\n<pre class=\"brush:bash\">ifconfig<\/pre>\n<p>If you try it, you will receive and output similar to the following:<\/p>\n<pre class=\"brush:bash\">eth0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr XX:XX:XX:XX:XX:XX \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCAST MULTICAST\u00a0 MTU:1500\u00a0 Metric:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 collisions:0 txqueuelen:1000 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:0 (0.0 B)\u00a0 TX bytes:0 (0.0 B)\r\n\r\nlo\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Local Loopback \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:127.0.0.1\u00a0 Mask:255.0.0.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 addr: ::1\/128 Scope:Host\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP LOOPBACK RUNNING\u00a0 MTU:65536\u00a0 Metric:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:3124 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:3124 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 collisions:0 txqueuelen:0 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:376288 (376.2 KB)\u00a0 TX bytes:376288 (376.2 KB)\r\n\r\nwlan0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr XX:XX:XX:XX:XX:XX \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:192.168.1.154\u00a0 Bcast:192.168.1.255\u00a0 Mask:255.255.255.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 addr: fe80::6627:37ff:feb3:592d\/64 Scope:Link\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCAST RUNNING MULTICAST\u00a0 MTU:1500\u00a0 Metric:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:72347 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:55487 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 collisions:0 txqueuelen:1000 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:82986485 (82.9 MB)\u00a0 TX bytes:7833391 (7.8 MB)<\/pre>\n<p>We can see three main information segments. Each of this segment is the information <strong>about each network interface<\/strong>. In this case, there are three: <code>eth0<\/code>, <code>lo<\/code>, and <code>wlan0<\/code>.<\/p>\n<p>You will probably be familiar to ethernet and WLAN interfaces, which are are for wired and unwired connections, respectively. But the loopback interface, <code>lo<\/code>, is quite special. <strong>The loopback interface is a virtual interface (does not rely in hardware) that the machines use to communicate with themselves<\/strong>. This interface has two main purposes:<\/p>\n<ul>\n<li>Troubleshooting.<\/li>\n<li>Running a local server.<\/li>\n<\/ul>\n<p>Now that we have identified the devices, let&#8217;s understand their properties and configurations:<\/p>\n<ul>\n<li><code>HWAddr<\/code>: hardware address, commonly known as MAC address. An unique identifier assigned to each network interface.<\/li>\n<li><code>inet addr<\/code>: the IP address of the interface.<\/li>\n<li><code>Bcast<\/code>: the broadcast address of the network.<\/li>\n<li><code>Mask<\/code>: the mask of the IP address. That is, the mask that indicates which part of the IP address corresponds to the network, and which to the hosts.<\/li>\n<li><code>inet6 addr<\/code>: the IPv6 address of the interface.<\/li>\n<li><code>UP<\/code>: the interface has been loaded.<\/li>\n<li><code>BROADCAST<\/code>: the interface supports broadcasting, i.e., sending\/receiving frames from\/to <strong>every host<\/strong> in the network, in a single transmission, by broadcast address.<\/li>\n<li><code>RUNNING<\/code>: the interface is ready to transmit and receive data.<\/li>\n<li><code>MULTICAST<\/code>: he interface supports multicasting, i.e., sending\/receiving from\/to <strong>interested hosts<\/strong> in the network. Note the difference with broadcasting.<\/li>\n<li><code>MTU<\/code>: he Maximum Transmission Unit. We will see this later in the tutorial.<\/li>\n<li><code>Metric<\/code>: the priority of the device. The lower number, the greater priority.<\/li>\n<li><code>RX packets<\/code>, <code>TX packets<\/code>: received and transmitted packages, respectively.<\/li>\n<li><code>RX bytes<\/code>, <code>TX bytes<\/code>: received and transmitted bytes, respectively.<\/li>\n<\/ul>\n<p>For seeing the information about a specific interface, we can specify it:<\/p>\n<pre class=\"brush:bash\">ifconfig eth0<\/pre>\n<h2 id=\"section_2\">2. Enabling and disabling interfaces<\/h2>\n<p>We can enable and disable the interfaces pretty easily. The syntax is the following:<\/p>\n<pre class=\"brush:bash\">ifconfig [interface] [up|down]<\/pre>\n<p>So, the following commands would disable the <code>eth0<\/code> interface, for then enabling it again:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig eth0 down\r\nsudo ifconfig eth0 up<\/pre>\n<p>Note that for this operations, we need superuser privileges.<\/p>\n<h2 id=\"section_3\">3. Changing IP addresses<\/h2>\n<h3 id=\"section_3_1\">3.1. IPv4<\/h3>\n<p>The assigned IP (and netmask and broadcast) can be changed executing <code>ifconfig<\/code> in the following way:<\/p>\n<pre class=\"brush:bash\">ifconfig [interface] [ip address] netmask [netmask] broadcast [broadcast ip]<\/pre>\n<p>For example, to change <code>wlan0<\/code> interface&#8217;s IP to, for instance, <code>192.168.1.30<\/code> address:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0 192.168.1.30<\/pre>\n<p>Now, if we check the configuration, we would see:<\/p>\n<pre class=\"brush:bash\">wlan0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr 64:27:37:b3:59:2d \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:192.168.1.30\u00a0 Bcast:192.168.1.255\u00a0 Mask:255.255.255.0\r\n<\/pre>\n<h4 id=\"section_3_1_1\">3.1.1 Considerations<\/h4>\n<p>Before changing this configurations, we must ensure several things:<\/p>\n<ul>\n<li><strong>The new IP has to be inside the network<\/strong>. In this case, we knew that the IP was 192.168.1.154 and the mask 255.255.255.0, so, the IP must be in the 192.168.1.2 &#8211; 192.168.1.254 range, inclusive. We discard the first and the last since they are the network and the broadcast addresses.<\/li>\n<li><strong>The new IP has to be free<\/strong>. If we assign an IP that is already assigned to another host, we won&#8217;t have connectivity.<\/li>\n<\/ul>\n<h3 id=\"section_3_2\">3.2. IPv6<\/h3>\n<p>In the previous section we have seen how to configure the IP addresses. As you probably already know, that corresponded to the fourth version of IP (IPv4).<\/p>\n<p>Progressively, the IP addresses will be migrated from IPv4 to IPv6 (even if they will coexist). So, a system administration must also master the IPv6 protocol.<\/p>\n<p>Returning to the <code>ifconfig<\/code> output, for both loopback and WLAN interfaces (the ethernet interface, in this case, is disabled):<\/p>\n<pre class=\"brush:bash;highlight:[3,9]\">lo\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Local Loopback \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:127.0.0.1\u00a0 Mask:255.0.0.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 addr: ::1\/128 Scope:Host\r\n\r\nwlan0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr 64:27:37:b3:59:2d \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:192.168.1.154\u00a0 Bcast:192.168.1.255\u00a0 Mask:255.255.255.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 addr: fe80::6627:37ff:feb3:592d\/64 Scope:Link\r\n<\/pre>\n<p>We can notice that our interface have already assigned an IPv6 address (lines 3, 9). The first, the one of the loopback interface is, as you probably has guessed, the equivalent of <code>127.0.0.1<\/code> for IPv6.<\/p>\n<p>For pinging IPv6 addresses, we have to use ping6 command, instead of ping:<\/p>\n<pre class=\"brush:bash\">ping6 ::1<\/pre>\n<p>And the packets should be correctly transmitted:<\/p>\n<pre class=\"brush:bash\">PING ::1(::1) 56 data bytes\r\n64 bytes from ::1: icmp_seq=1 ttl=64 time=0.028 ms\r\n<\/pre>\n<p>We can add IPv6 addresses to interfaces:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0 inet6 add fe80::6627:37ff:feb3:592e\/64<\/pre>\n<p>As same as modifying, but adding the <code>inet6<\/code> (for IPv6) and <code>add<\/code> options.<\/p>\n<p>If we check now the interface&#8230;<\/p>\n<pre class=\"brush:bash\">wlan0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr 64:27:37:b3:59:2d \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:192.168.1.155\u00a0 Bcast:192.168.1.255\u00a0 Mask:255.255.255.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 addr: fe80::6627:37ff:feb3:592e\/64 Scope:Link\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 addr: fe80::6627:37ff:feb3:592d\/64 Scope:Link<\/pre>\n<p>We can see that our WLAN interface has now two IPv6 addresses.<\/p>\n<p>To delete a IPv6 address, we have to do the same, but with <code>del<\/code> option instead of <code>add<\/code>:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0 inet6 del fe80::6627:37ff:feb3:592e\/64<\/pre>\n<h3 id=\"section_3_3\">3.3. Change from static IP to DHCP<\/h3>\n<p>This is not exactly an <code>ifconfig<\/code> function. But is something we would have to do if we entered an incorrect IP, and we want to forget it, and delegate the IP assignment to the DHCP protocol.<\/p>\n<p>For that, we just have to type:<\/p>\n<pre class=\"brush:bash\">sudo dhclient &lt;interface&gt;<\/pre>\n<h2 id=\"section_4\">4. Using virtual IP addresses<\/h2>\n<p>Also called aliases, these IP addresses are additional addresses to the interfaces. So, an interface could listen to several IP addresses.<\/p>\n<p>If the IP address of the <code class=\"plain\">wlan0<\/code> interface was <code class=\"plain\">192.168.1.154<\/code>, we could add, for example, the\u00a0<code class=\"plain\">192.168.1.155<\/code> address:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0:0 192.168.1.155<\/pre>\n<p>Which would generate another output for <code class=\"plain\">ifconfig<\/code>, just as another interface more:<\/p>\n<pre class=\"brush:bash\">wlan0:0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr XX:XX:XX:XX:XX:XX\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:192.168.1.155\u00a0 Bcast:192.168.1.255\u00a0 Mask:255.255.255.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCAST RUNNING MULTICAST\u00a0 MTU:1500\u00a0 Metric:1<\/pre>\n<p>Each virtual interface must follow the <code class=\"plain\">&lt;interface&gt;:n<\/code> format, where <code class=\"plain\">n<\/code> is any positive number (including 0), and unique to each virtual interface.<\/p>\n<p>For example, if we have running a web server in the machine, now would be accessible from both <code class=\"plain\">192.168.1.154<\/code> and <code class=\"plain\">192.168.1.155<\/code> addresses. Using virtual IP addresses is specially useful when we want to server several services in the same machine, but for different IP addresses.<\/p>\n<p>To remove a virtual interface, we have to set it down:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0:0 down<\/pre>\n<h2 id=\"section_5\">5. Changing MTU<\/h2>\n<p>By default, for ethernet, the maximum transmission unit (i.e., the size in bytes of the largest data unit that can be transmitted), is 1500. But this value can be easily changed:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig eth0 mtu 2000<\/pre>\n<h3 id=\"section_5_1\">5.1. Finding best MTU size<\/h3>\n<p><strong>This is not a likely option to change<\/strong>. But there are mechanisms to find the best MTU values.<\/p>\n<p>The problem is that, if the size is too small, the packets are smaller and they are transmitted faster, but this can suppose an overhead due to the acknowledgment and handling of each packet. And, if the size is too large, a router in the packet route may drop the packet.<\/p>\n<p>To find the equilibrium, we can make some tests manually with\u00a0<code>ping<\/code>. We can start making pings with the default value, 1500:<\/p>\n<pre class=\"brush:bash\">ping -M do -c 1 -s 1472 www.systemcodegeeks.com<\/pre>\n<p>The size specified here is 1472, but because the the IP\/ICMP header of 28 bytes is not included.<\/p>\n<p>We can increase this value while we success response:<\/p>\n<pre class=\"brush:bash\">1472 bytes from 104.27.130.144: icmp_seq=1 ttl=56 time=38.0 ms\r\n\r\n--- systemcodegeeks.com ping statistics ---\r\n1 packets transmitted, 1 received, 0% packet loss, time 0ms<\/pre>\n<p>And, until we get an error message:<\/p>\n<pre class=\"brush:bash\">ping: local error: Message too long, mtu=1600\r\n\r\n--- systemcodegeeks.com ping statistics ---\r\n1 packets transmitted, 0 received, +1 errors, 100% packet loss, time 0ms<\/pre>\n<p><strong>The best MTU size would be the larger one that does not return an error, plus 28<\/strong> (the previous mentioned header size).<\/p>\n<h2 id=\"section_6\">6. Changing MAC address<\/h2>\n<p>Yes, <code>ifconfig<\/code> allows to change the physical address of a network interface.<\/p>\n<p>Well, that&#8217;s not exactly true. The physical addresses of devices cannot be changed, but what it can be changed is the address that is loaded into the memory.<\/p>\n<p>This is pretty easy to do with <code>ifconfig<\/code>:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig eth0 down\r\nsudo ifconfig eth0 hw ether XX:XX:XX:XX:XX:XX\r\nsudo ifconfig eth0 up\r\nsudo ifconfig eth0<\/pre>\n<p>(Placing a real MAC address where <code>XX:XX:XX:XX:XX:XX<\/code> is placed).<\/p>\n<p>We can check that effectively the physical address has been changed:<\/p>\n<pre class=\"brush:bash\">eth0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr XX:XX:XX:XX:XX:XX<\/pre>\n<p>Take into account that what we are doing is to change the loaded address into memory, so, this is only temporary: <strong>if the device is rebooted, the real physical address will be loaded<\/strong>.<\/p>\n<p>Changing the MAC address can be useful, for example, for privacy when connected to public networks, not to show the real physical address; or to bypass MAC security filters.<\/p>\n<h2 id=\"section_7\">7. Promiscuous mode<\/h2>\n<p>The promiscuous mode is a mode where a device connected to a network captures all the traffic traveling through that network.<\/p>\n<p>This is not as obvious as it can appear. If you have ever used a packet sniffer such us Wireshark, in a &#8220;simple&#8221; LAN (multiple devices connected to a router, for instance) you may have successfully sniffed other devices&#8217; packets. But, if you have used it in a switched network (not <em>hubed<\/em>), you will probably have noticed that is not that easy to sniff packets. This is because the switches forward the frames only to the devices that need that frames, instead of sending broadcasts.<\/p>\n<p>To put an interface (<code>wlan0<\/code>, for example) in promiscuous mode, we only have to type:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0 promisc<\/pre>\n<p>The <code>ifconfig<\/code> output will say if an interface is in promiscuous mode:<\/p>\n<pre class=\"brush:bash;highlight:[4]\">wlan0\u00a0\u00a0\u00a0\u00a0 Link encap:Ethernet\u00a0 HWaddr 64:27:37:b3:59:2d \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:192.168.1.154\u00a0 Bcast:192.168.1.255\u00a0 Mask:255.255.255.0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet6 addr: fe80::6627:37ff:feb3:592d\/64 Scope:Link\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP BROADCAST RUNNING PROMISC MULTICAST\u00a0 MTU:1500\u00a0 Metric:1<\/pre>\n<p>To put the interface in normal mode, we have to enter:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0 -promisc<\/pre>\n<h2 id=\"section_8\">8. ARP mode<\/h2>\n<p>ARP acronym stands for Address Resolution Protocol, a network layer protocol, used for finding physical addresses corresponding to certain IPs, in order to populate ARP tables, where the IPs and MAC addresses are stored in key-value format.<\/p>\n<p>The use of this protocol can cause some trouble, including DDOS attacks or spoofing. So, in some cases may be wanted to disable it.<\/p>\n<p>The mechanism to enable\/disable the ARP mode is the same as with promiscuous mode:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0 arp  # Enables ARP for the wlan0 interface.\r\nsudo ifconfig wlan0 -apr # Disables ARP for the wlan0 interface.<\/pre>\n<h2 id=\"section_9\">9. Broadcast and multicast modes<\/h2>\n<p>As same as with ARP mode, we may be interested in disabling broadcast and\/or multicast to avoid possible floods.<\/p>\n<p>Again, the mechanism is the same:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig wlan0 -multicast # Disables multicast for wlan0 interface.\r\nsudo ifconfig wlan0 -broadcast # Disables broadcast for wlan0 interface.\r\nsudo ifconfig wlan0 multicast  # Enables multicast for wlan0 interface.\r\nsudo ifconfig wlan0 broadcast  # Enables broadcast for wlan0 interface.<\/pre>\n<h2 id=\"section_10\">10. IP tunneling<\/h2>\n<p>The IP tunnel creation is a feature of <code>ifconfig<\/code> that must be mentioned.<\/p>\n<p>An IP tunnel is a network communication channel where the data frames are transformed to pass networks without a routing path, or even incompatible protocols. The most common uses of IP tunnels are for creating Virtual Private Networks (along with IPSec procotol), and to connect IPv4 installations with IPv6 ones.<\/p>\n<p>First, we have to create the IP tunnel, which will be like another network interface, with <code>ip<\/code> command:<\/p>\n<pre class=\"brush:bash\">sudo ip tunnel add tun0 mode ipip remote &lt;remote_ip&gt; local &lt;local_ip&gt; dev &lt;device&gt;<\/pre>\n<p>Let&#8217;s see it carefully:<\/p>\n<ul>\n<li><code>tun0<\/code> is be the name the tunnel will have.<\/li>\n<li><code>ipip<\/code> is the tunnel mode. The IPIP kind tunnels are the simplest ones: they can only handle IPv4 multicast frames. The other option is GRE, which is the one used when tunneling routing protocols such us OSPF.<\/li>\n<li>The remote and local IPs would be the two endpoints of the tunnel.<\/li>\n<li>The device is the interface of the local IP, where the tunnel will be created.<\/li>\n<\/ul>\n<p>So, for creating a tunnel between <code>X.X.X.X<\/code> and <code>Y.Y.Y.Y<\/code> IPs, we could do:<\/p>\n<pre class=\"brush:bash\">sudo ip tunnel add tun0 mode ipip remote X.X.X.X local Y.Y.Y.Y dev wlan0<\/pre>\n<p>This will create a <code>tun0<\/code> interface. Now, we have to assign an IP address to the interface:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig tun0 172.0.0.1 netmask 255.255.255.252 pointopoint 172.0.0.2 dev eth0<\/pre>\n<p>The <code>pointopoint<\/code> option is for enabling the point-to-point mode, i.e., a direct link between two devices.<\/p>\n<p>We can see the tunnel configuration as any other network device, typing <code>ifconfig tun0<\/code>:<\/p>\n<pre class=\"brush:bash\">tun0\u00a0\u00a0\u00a0\u00a0\u00a0 Link encap:IPIP Tunnel\u00a0 HWaddr\u00a0 \u00a0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 inet addr:172.0.0.1\u00a0 P-t-P:172.0.0.2\u00a0 Mask:255.255.255.252\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 UP POINTOPOINT RUNNING NOARP\u00a0 MTU:1480\u00a0 Metric:1\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX packets:0 errors:0 dropped:0 overruns:0 frame:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 TX packets:0 errors:0 dropped:0 overruns:0 carrier:0\r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 collisions:0 txqueuelen:0 \r\n\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 RX bytes:0 (0.0 B)\u00a0 TX bytes:0 (0.0 B)<\/pre>\n<p>Note that the MTU is set to 1480. Let&#8217;s change it to ethernet default value, 1500:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig tun0 mtu 1500<\/pre>\n<p>Finally, we have to bring up the interface:<\/p>\n<pre class=\"brush:bash\">sudo ifconfig tun0 up<\/pre>\n<p>And that&#8217;s it. To delete that tunnel, we would just have to type:<\/p>\n<pre class=\"brush:bash\">sudo ip tunnel del tun0<\/pre>\n<h2 id=\"section_11\">11. Summary<\/h2>\n<p>This tutorial has shown how to use the essential <code>ifconfig<\/code> command, from showing the most basic information about the network interfaces and changing IP addresses, to advanced topics such as creating IP tunnels or changing MAC addresses and packets&#8217; maximum sizes.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is ifconfig (contraction of interface and configuration), which allows to make almost any configuration in a network, as we will see in this tutorial. Basic knowledge about networking (what IP addresses are, their &hellip;<\/p>\n","protected":false},"author":25,"featured_media":192,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[7],"tags":[],"class_list":["post-1357","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-linux"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Linux IfConfig Tutorial - System Code Geeks - 2026<\/title>\n<meta name=\"description\" content=\"The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is ifconfig\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux IfConfig Tutorial - System Code Geeks - 2026\" \/>\n<meta property=\"og:description\" content=\"The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is ifconfig\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"System Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/systemcodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2016-06-13T14:15:27+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Toni\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@systemcodegeeks\" \/>\n<meta name=\"twitter:site\" content=\"@systemcodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Toni\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"12 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/\"},\"author\":{\"name\":\"Toni\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/69a7de154310f99cedabb63c580291b2\"},\"headline\":\"Linux IfConfig Tutorial\",\"datePublished\":\"2016-06-13T14:15:27+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/\"},\"wordCount\":1777,\"commentCount\":1,\"publisher\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg\",\"articleSection\":[\"Linux\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/\",\"url\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/\",\"name\":\"Linux IfConfig Tutorial - System Code Geeks - 2026\",\"isPartOf\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg\",\"datePublished\":\"2016-06-13T14:15:27+00:00\",\"description\":\"The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is ifconfig\",\"breadcrumb\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage\",\"url\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg\",\"contentUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg\",\"width\":150,\"height\":150},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.systemcodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux\",\"item\":\"https:\/\/www.systemcodegeeks.com\/category\/linux\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Linux IfConfig Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#website\",\"url\":\"https:\/\/www.systemcodegeeks.com\/\",\"name\":\"System Code Geeks\",\"description\":\"Operating System Developers Resource Center\",\"publisher\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.systemcodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/www.systemcodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/systemcodegeeks\",\"https:\/\/x.com\/systemcodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/69a7de154310f99cedabb63c580291b2\",\"name\":\"Toni\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g\",\"caption\":\"Toni\"},\"url\":\"https:\/\/www.systemcodegeeks.com\/author\/julen-pardo\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Linux IfConfig Tutorial - System Code Geeks - 2026","description":"The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is ifconfig","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"Linux IfConfig Tutorial - System Code Geeks - 2026","og_description":"The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is ifconfig","og_url":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/","og_site_name":"System Code Geeks","article_publisher":"https:\/\/www.facebook.com\/systemcodegeeks","article_published_time":"2016-06-13T14:15:27+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg","type":"image\/jpeg"}],"author":"Toni","twitter_card":"summary_large_image","twitter_creator":"@systemcodegeeks","twitter_site":"@systemcodegeeks","twitter_misc":{"Written by":"Toni","Est. reading time":"12 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#article","isPartOf":{"@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/"},"author":{"name":"Toni","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/69a7de154310f99cedabb63c580291b2"},"headline":"Linux IfConfig Tutorial","datePublished":"2016-06-13T14:15:27+00:00","mainEntityOfPage":{"@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/"},"wordCount":1777,"commentCount":1,"publisher":{"@id":"https:\/\/www.systemcodegeeks.com\/#organization"},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg","articleSection":["Linux"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/","url":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/","name":"Linux IfConfig Tutorial - System Code Geeks - 2026","isPartOf":{"@id":"https:\/\/www.systemcodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg","datePublished":"2016-06-13T14:15:27+00:00","description":"The network configuration is one of the first topics a system administrator gets involved with. For Linux, the command to configure this is ifconfig","breadcrumb":{"@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#primaryimage","url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg","contentUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2016\/01\/linux-logo.jpg","width":150,"height":150},{"@type":"BreadcrumbList","@id":"https:\/\/www.systemcodegeeks.com\/linux\/linux-ifconfig-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.systemcodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Linux","item":"https:\/\/www.systemcodegeeks.com\/category\/linux\/"},{"@type":"ListItem","position":3,"name":"Linux IfConfig Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/www.systemcodegeeks.com\/#website","url":"https:\/\/www.systemcodegeeks.com\/","name":"System Code Geeks","description":"Operating System Developers Resource Center","publisher":{"@id":"https:\/\/www.systemcodegeeks.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.systemcodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.systemcodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/www.systemcodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/www.systemcodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/systemcodegeeks","https:\/\/x.com\/systemcodegeeks"]},{"@type":"Person","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/69a7de154310f99cedabb63c580291b2","name":"Toni","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.systemcodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/21c1661474c78b4757355b8beef9ab1d14f490ee3a3e67392f4e618d36643d4c?s=96&d=mm&r=g","caption":"Toni"},"url":"https:\/\/www.systemcodegeeks.com\/author\/julen-pardo\/"}]}},"_links":{"self":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts\/1357","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/users\/25"}],"replies":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/comments?post=1357"}],"version-history":[{"count":0,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/posts\/1357\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/media\/192"}],"wp:attachment":[{"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/media?parent=1357"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/categories?post=1357"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.systemcodegeeks.com\/wp-json\/wp\/v2\/tags?post=1357"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}