{"id":1807,"date":"2021-09-11T10:40:20","date_gmt":"2021-09-11T10:40:20","guid":{"rendered":"https:\/\/ownwebservers.com\/kb\/?p=1807"},"modified":"2021-09-13T10:56:49","modified_gmt":"2021-09-13T10:56:49","slug":"how-to-enable-ip-forwarding-on-linux-ipv4-ipv6","status":"publish","type":"post","link":"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/","title":{"rendered":"How to enable IP forwarding on Linux (IPv4 \/ IPv6)?"},"content":{"rendered":"<p>For an operating system to simply accept incoming network packets on one interface, IP forwarding has the ability of it, identifying that it&#8217;s not meant for the system itself, however it should be forwarded on to a different network, then forward accordingly.<\/p>\n<p>By default, any latest Linux system distributions can have IP Forwarding disabled. Thus, it&#8217;s a decent plan, as several users won&#8217;t would like IP Forwarding, but, What if we are setting up a Linux router\/gateway or a VPN server or just a plain dial-in server then we tend to should have to be compelled to enable forwarding.<\/p>\n<p>IP Forwarding Overview<\/p>\n<p>In this article we&#8217;ll see the way to enable IP forwarding on Linux system, it&#8217;s a reasonably easy procedure and that we can find out how to make this temporary or permanent on the system. IP forwarding allows an operating system (here on Linux) to forward packets as a router will or additional typically to route them through alternative networks. The activation of IP forwarding is commonly used once being listening to the network (Man within the middle attack in particular) but also more simply when trying to make a Linux machine a router between several networks.<\/p>\n<p><em><strong>Let\u2019s check out how to Enable IP Forwarding:<\/strong><\/em><\/p>\n<p>Firstly, we need to check the Current IP forwarding status.<\/p>\n<p><em><strong>Check if IP Forwarding is enabled or not:<\/strong><\/em><\/p>\n<p>Here we have to query the\u00a0<strong>sysctl kernel<\/strong>\u00a0value\u00a0<strong>net.ipv4.ip_forward<\/strong>\u00a0to check if IP forwarding is enabled or not: Using\u00a0<strong>sysctl<\/strong>:<\/p>\n<pre><strong>sysctl net.ipv4.ip_forward<\/strong>\r\n<strong>net.ipv4.ip_forward = 0<\/strong><\/pre>\n<p>Or just check out the value in the\u00a0<strong>\/proc<\/strong>\u00a0system:<\/p>\n<pre><strong>cat \/proc\/sys\/net\/ipv4\/ip_forward<\/strong>\r\n<strong>0<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1808\" src=\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-1-300x39.png\" alt=\"linux-1\" width=\"830\" height=\"108\" srcset=\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-1-300x39.png 300w, https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-1-768x100.png 768w, https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-1.png 830w\" sizes=\"auto, (max-width: 830px) 100vw, 830px\" \/><\/p>\n<p>As per the above examples, we can see this was\u00a0<em>disabled<\/em>\u00a0(as shown by the\u00a0<strong>value 0<\/strong>).<\/p>\n<h4><strong>Temporary Activation<\/strong><\/h4>\n<p>The activation and deactivation of IP forwarding, in IPv4, as does IPv6 is handled in \/proc files. This is\u00a0<strong>\u201c<em>\/proc\/sys\/net\/ipv4\/ip_forward<\/em>\u201d for IPv4 and \u201c<em>\/proc\/sys\/net\/ipv6\/conf\/all\/forwarding<\/em>\u201d<\/strong>\u00a0for IPv6.<\/p>\n<p>If we do a \u201c<strong><em>cat<\/em><\/strong>\u201d on these files, we will see that they are by default to 0, to activate the IP forwarding temporarily, it is enough to put them at 1. One can then modify the file or use the \u201c<strong>sysctl<\/strong>\u201d command:<\/p>\n<pre>| sysctl -w net.ipv4.ip_forward=1<\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1809\" src=\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-2-300x50.png\" alt=\"linux-2\" width=\"841\" height=\"141\" srcset=\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-2-300x50.png 300w, https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-2-768x129.png 768w, https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-2.png 841w\" sizes=\"auto, (max-width: 841px) 100vw, 841px\" \/><\/p>\n<p>Or, following is one more command to enable temporary:<\/p>\n<pre>| echo 1 &gt; \/proc\/sys\/net\/ipv4\/ip_forward<\/pre>\n<p>The temporary change, of course, means that the parameters will return to their default value when the machine restarts or \u201csysctl\u201d restarts if it is done manually.<\/p>\n<p>Now, let\u2019s check out the Permanent Solution for it.<\/p>\n<h4><strong>Permanent Activation<\/strong><\/h4>\n<p>To enable these changes permanently, you have to modify the configuration file of sysctl so that it loads our modifications each start. It is the file \u201c<strong><em>\/etc\/sysctl.conf<\/em><\/strong>\u201d to activate IPv4 IP forwarding. We will add or uncomment this line:<\/p>\n<pre><strong>| net.ipv4.ip_forward = 1<\/strong><\/pre>\n<p>For IPv6, we will do the same with this line:<\/p>\n<pre><strong>| net.ipv6.conf.all.forwarding=1<\/strong><\/pre>\n<p>The configuration can then be reloaded so that the changes take effect immediately:<\/p>\n<pre><strong>| sysctl -p \/etc\/sysctl.conf<\/strong><\/pre>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-medium wp-image-1810\" src=\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-3-300x183.png\" alt=\"linux-3\" width=\"601\" height=\"366\" srcset=\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-3-300x183.png 300w, https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-3.png 601w\" sizes=\"auto, (max-width: 601px) 100vw, 601px\" \/><\/p>\n<p>That\u2019s it! You have successfully performed the activation.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>For an operating system to simply accept incoming network packets on one interface, IP forwarding has the ability of it, identifying that it&#8217;s not meant for the system itself, however it should be forwarded on to a different network, then forward accordingly. By default, any latest Linux system distributions can have IP Forwarding disabled. Thus, [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-1807","post","type-post","status-publish","format-standard","hentry","category-tutorials"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v15.2.1 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>How to enable IP forwarding on Linux (IPv4 \/ IPv6)? - OWS KB<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"How to enable IP forwarding on Linux (IPv4 \/ IPv6)? - OWS KB\" \/>\n<meta property=\"og:description\" content=\"For an operating system to simply accept incoming network packets on one interface, IP forwarding has the ability of it, identifying that it&#8217;s not meant for the system itself, however it should be forwarded on to a different network, then forward accordingly. By default, any latest Linux system distributions can have IP Forwarding disabled. Thus, [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/\" \/>\n<meta property=\"og:site_name\" content=\"OWS KB\" \/>\n<meta property=\"article:published_time\" content=\"2021-09-11T10:40:20+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-09-13T10:56:49+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-1-300x39.png\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\">\n\t<meta name=\"twitter:data1\" content=\"admin\">\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\">\n\t<meta name=\"twitter:data2\" content=\"2 minutes\">\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/#website\",\"url\":\"https:\/\/ownwebservers.com\/kb\/\",\"name\":\"OWS KB\",\"description\":\"\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/ownwebservers.com\/kb\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/#primaryimage\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/ownwebservers.com\/kb\/wp-content\/uploads\/2021\/09\/linux-1.png\",\"width\":830,\"height\":108,\"caption\":\"linux-1\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/#webpage\",\"url\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/\",\"name\":\"How to enable IP forwarding on Linux (IPv4 \/ IPv6)? - OWS KB\",\"isPartOf\":{\"@id\":\"https:\/\/ownwebservers.com\/kb\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/#primaryimage\"},\"datePublished\":\"2021-09-11T10:40:20+00:00\",\"dateModified\":\"2021-09-13T10:56:49+00:00\",\"author\":{\"@id\":\"https:\/\/ownwebservers.com\/kb\/#\/schema\/person\/4a40fe3fe17a08ddd1d7c113668e75f2\"},\"breadcrumb\":{\"@id\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/\",\"url\":\"https:\/\/ownwebservers.com\/kb\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/\",\"url\":\"https:\/\/ownwebservers.com\/kb\/how-to-enable-ip-forwarding-on-linux-ipv4-ipv6\/\",\"name\":\"How to enable IP forwarding on Linux (IPv4 \/ IPv6)?\"}}]},{\"@type\":\"Person\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/#\/schema\/person\/4a40fe3fe17a08ddd1d7c113668e75f2\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\/\/ownwebservers.com\/kb\/#personlogo\",\"inLanguage\":\"en-US\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/ba5db5841d48bd7517bb2583e13983e6d2fa56a4099a0b3c61ad2daefc321303?s=96&d=mm&r=g\",\"caption\":\"admin\"},\"sameAs\":[\"https:\/\/ownwebservers.com\/kb\"]}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","_links":{"self":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/1807","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/comments?post=1807"}],"version-history":[{"count":3,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/1807\/revisions"}],"predecessor-version":[{"id":1849,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/posts\/1807\/revisions\/1849"}],"wp:attachment":[{"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/media?parent=1807"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/categories?post=1807"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ownwebservers.com\/kb\/wp-json\/wp\/v2\/tags?post=1807"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}