{"id":39340,"date":"2026-07-03T03:58:04","date_gmt":"2026-07-03T10:58:04","guid":{"rendered":"https:\/\/www.privateinternetaccess.com\/blog\/?p=39340"},"modified":"2026-07-03T04:05:54","modified_gmt":"2026-07-03T11:05:54","slug":"linux-ip-forwarding","status":"publish","type":"post","link":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/","title":{"rendered":"Linux IP Forwarding: Complete Setup Guide"},"content":{"rendered":"\n<p class=\"wp-block-paragraph\"><strong>Linux IP forwarding is essential for many advanced networking tasks<\/strong>, but enabling it without the right configuration can create unintended security and connectivity issues. Whether you\u2019re setting up a router, gateway, VPN, or another network service in Linux, it\u2019s important to know when to enable IP forwarding, how to configure it, and when to disable it.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">This guide shows you how to check whether Linux IP forwarding is on and how to enable it temporarily or permanently. You\u2019ll also learn how to troubleshoot common issues and turn it off when you\u2019re done.<\/p>\n\n\n\n<div style=\"background-color: #d5dde3; padding: 15px; border-radius: 10px; max-width: 500px;\">\n<h4>Table of Contents<\/h4>\n<a href=\"#WhatisIP\">What Is IP Forwarding in Linux?<\/a><br>\n<a href=\"#HowtoEnable\">How to Enable IP Forwarding on Linux<\/a><br>\n<a href=\"#HowtoDisable\">How to Disable IP Forwarding on Linux<\/a><br>\n<a href=\"#Troubleshooting\">Troubleshooting Linux IP Forwarding<\/a><br>\n<a href=\"#WhenShould\">When Should You Use IP Forwarding on Linux?<\/a><br>\n<a href=\"#LinuxIP\">Linux IP Forwarding Risks<\/a><br>\n<a href=\"#FAQ\">FAQ<\/a><br><\/div>\n\n\n\n\n<p><\/p>\n\n\n<div style=\"background-color: #cfe2f3; padding: 1em; border-radius: 1em;\"><h2 id=\"WhatisIP\" class=\"wp-block-heading\">What Is IP Forwarding in Linux?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Linux IP forwarding is a kernel-level feature<\/strong><strong><sup>1<\/sup><\/strong><strong> that lets the system forward IP packets between network interfaces<\/strong>, essentially turning your Linux machine into a router. It\u2019s turned off by default, so a Linux machine only handles packets meant for its own IP address and drops any packets addressed to a different interface. When you enable it, the system checks the destination IP against its routing table and forwards each packet to the right network interface.<\/p><\/div>\n\n\n\n<h2 id=\"HowtoEnable\" class=\"wp-block-heading\">How to Enable IP Forwarding on Linux<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">The steps below show how to check whether you\u2019ve enabled IP forwarding and how to turn it on. You have two ways to do this. A temporary change applies right away but resets after a reboot, while a permanent change survives restarts.<\/p>\n\n\n\n<h3 id=\"h-check-if-ip-forwarding-is-enabled\" class=\"wp-block-heading\">Check If IP Forwarding Is Enabled<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">First, check whether IP forwarding is already on:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Terminal (press Ctrl+Alt+T)<em>.<\/em><\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>To check whether IPv4 forwarding is set up, run echo 1 | sudo tee \/proc\/sys\/net\/ipv4\/ip_forward and press <em>Enter<\/em>.\u00a0<\/li>\n<\/ol>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>For IPv6, type <code>echo 1 | sudo tee \/proc\/sys\/net\/ipv6\/conf\/all\/forwarding<\/code> and press <em>Enter.<\/em><\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-2-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with the IPv6 forwarding check command entered\" class=\"wp-image-39346\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-2-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-2-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-2-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-2-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-2-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-2.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">In both cases, a value of 1 in the command output means that IP forwarding is on, and 0 means it\u2019s disabled.<\/p>\n\n\n\n<h3 id=\"h-enable-ip-forwarding-temporarily\" class=\"wp-block-heading\">Enable IP Forwarding Temporarily<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Terminal<em>.<\/em><\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>For IPv4, type sudo sysctl -w net.ipv4.ip_forward=1<strong>, <\/strong>press <em>Enter,<\/em> and enter your password if prompted. (Don\u2019t worry if nothing appears on the screen when you\u2019re typing your password \u2013 this is to stop anyone from reading your password over your shoulder.)<\/li>\n<\/ol>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>For IPv6, type <code>sudo sysctl -w net.ipv6.conf.all.forwarding=1<\/code>, press <em>Enter,<\/em> and enter your password if prompted.<\/li>\n<\/ol>\n\n\n\n<p class=\"wp-block-paragraph\">On setups without systemd or sysctl, you can enable forwarding through the kernel command line instead. Add <code>net.ipv4.ip_forward=1<\/code> and <code>net.ipv6.conf.all.forwarding=1<\/code> to <code>\/etc\/default\/grub<\/code>, then rebuild the bootloader with <code>sudo update-grub<\/code>.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">To confirm it worked, run the check command from above and make sure the values now show 1.\u00a0<\/p>\n\n\n\n<h3 id=\"Permanently\" class=\"wp-block-heading\">Enable IP Forwarding Permanently<\/h3>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Terminal, run <code>sudo nano \/etc\/sysctl.conf<\/code>, and enter your password if prompted.<\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Scroll through the <em>sysctl.conf <\/em>file and find the <code>net.ipv4.ip_forward = 1<\/code> and <code>net.ipv6.conf.all.forwarding = 1<\/code> lines.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-11-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with IPv4 and IPv6 forwarding options in the sysctl.conf file commented out\" class=\"wp-image-39367\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-11-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-11-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-11-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-11-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-11-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-11.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Uncomment <code>net.ipv4.ip_forward = 1<\/code> to enable IPv4 forwarding and <code>net.ipv6.conf.all.forwarding = 1 <\/code> to enable IPv6 forwarding. You can do so by removing the <strong><em>#<\/em><\/strong> sign at the start of each line.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-5-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with IPv4 and IPv6 forwarding options in the sysctl.conf file enabled\" class=\"wp-image-39348\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-5-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-5-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-5-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-5-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-5-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-5.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Press <em>Ctrl + O<\/em><strong> <\/strong>to write to the file, then press <em>Enter<\/em><strong> <\/strong>when you see the File name to write: \/etc\/sysctl.conf<strong> <\/strong>prompt.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-8-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with the prompt confirming to write to the sysctl.conf file\" class=\"wp-image-39352\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-8-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-8-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-8-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-8-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-8-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-8.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<ol start=\"5\" class=\"wp-block-list\">\n<li>Press <em>Ctrl + X<\/em><strong> <\/strong>to return to the terminal once you see a Wrote [X] lines<strong> <\/strong>prompt.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-9-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with the text editor confirming that the sysctl.conf file has been updated\" class=\"wp-image-39351\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-9-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-9-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-9-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-9-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-9-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-9.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<ol start=\"6\" class=\"wp-block-list\">\n<li>Run <code>sudo sysctl -p<\/code> to apply the changes.\u00a0<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-1-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with the command to apply the changes made to the sysctl.conf file\" class=\"wp-image-39345\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-1-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-1-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-1-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-1-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-1-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-1.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<h2 id=\"HowtoDisable\" class=\"wp-block-heading\">How to Disable IP Forwarding on Linux<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>Disabling Linux IP forwarding follows the same process as enabling it, just with the values reversed<\/strong>. If you enabled it temporarily, set the value to 0 in the sysctl -w command. If you enabled it permanently, comment out the <code>net.ipv4.ip_forward = 1<\/code> and <code>net.ipv6.conf.all.forwarding = 1<\/code> lines in the sysctl.conf<strong> <\/strong>file by adding <em>#<\/em> to the start of each line.<\/p>\n\n\n\n<h2 id=\"Troubleshooting\" class=\"wp-block-heading\">Troubleshooting Linux IP Forwarding<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Most Linux IP forwarding problems come down to settings that don\u2019t survive a reboot, traffic that won\u2019t route even though you enabled forwarding, or a sysctl service that isn\u2019t running. The steps below help you diagnose and fix each one.<\/p>\n\n\n\n<h3 id=\"h-change-not-persisting-after-reboot\" class=\"wp-block-heading\">Change Not Persisting After Reboot<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you have to re-enable Linux IP forwarding after every reboot, you\u2019re probably setting it temporarily with the <code>sysctl -w<\/code> command, which only lasts until the next restart. Follow the steps to <a href=\"#Permanently\" type=\"internal\" id=\"#Permanently\">permanently enable IP forwarding<\/a> to resolve the problem. It writes the setting into the sysctl.conf file, and the system reads that file on every boot, so the change sticks.<\/p>\n\n\n\n<h3 id=\"h-traffic-still-not-forwarding-despite-enabling-the-setting\" class=\"wp-block-heading\">Traffic Still Not Forwarding Despite Enabling the Setting<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If you enabled IP forwarding but traffic still isn\u2019t routing, the problem could be the FORWARD chain in iptables, which filters packets that don\u2019t originate from the host machine and aren\u2019t addressed to it. These steps will help:<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Terminal, run <code>sudo iptables -L FORWARD -v -n<\/code>, and enter your password if prompted. This shows the FORWARD chain policy.<\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Check the policy. If it\u2019s set to DROP and no rules allow your forwarded traffic, the FORWARD chain is blocking it, so continue with the steps below. If it says ACCEPT, the FORWARD chain isn\u2019t the cause and the problem likely lies elsewhere. Check that you\u2019ve applied the forward settings or if another firewall rule is blocking the traffic.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-7-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with the iptables forwarding policy set to DROP\" class=\"wp-image-39350\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-7-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-7-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-7-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-7-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-7-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-7.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Run <code>ip a<\/code> to find the names of the two interfaces you want to forward between. Then add rules allowing forwarding in that direction, with return traffic limited to established connections. Replace <code>eth1<\/code> and <code>eth0<\/code> in the commands below with your own interface names:<br><code>sudo iptables -A FORWARD -i eth1 -o eth0 -j ACCEPT<\/code><br><code>sudo iptables -A FORWARD -i eth0 -o eth1 -m state --state RELATED,ESTABLISHED -j ACCEPT<\/code>.\u00a0<\/li>\n<\/ol>\n\n\n\n<ol start=\"4\" class=\"wp-block-list\">\n<li>Run <code>sudo iptables -L FORWARD -v -n<\/code> again<strong> <\/strong>to confirm your new rules now appear in the FORWARD chain. The default policy will still show DROP. The rules you added are what permit your specific traffic.<\/li>\n<\/ol>\n\n\n\n<figure class=\"wp-block-image size-large\"><img loading=\"lazy\" decoding=\"async\" width=\"1024\" height=\"576\" style=\"margin-bottom: 15px; margin-top: 15px; border: 1px solid #aaa;\" src=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-6-1024x576.png\" alt=\"Screenshot showing the terminal in Ubuntu Linux with the iptables forwarding policy set to ACCEPT\" class=\"wp-image-39349\" srcset=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-6-1024x576.png 1024w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-6-300x169.png 300w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-6-768x432.png 768w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-6-1536x864.png 1536w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-6-1200x675.png 1200w, https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/image-6.png 1920w\" sizes=\"auto, (max-width: 709px) 85vw, (max-width: 909px) 67vw, (max-width: 1362px) 62vw, 840px\" \/><\/figure>\n\n\n\n<p class=\"wp-block-paragraph\">Adding rules for only the interfaces you need is safer than setting the whole FORWARD policy to ACCEPT, which would let all forwarded traffic through. That\u2019s worth avoiding on a production or internet-facing machine.<\/p>\n\n\n\n<h3 id=\"h-sysctl-service-not-running\" class=\"wp-block-heading\">Sysctl Service Not Running<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If neither of the steps above works, Linux may not be applying your settings. These steps will reapply them.<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li>Open the Terminal<em>.<\/em><\/li>\n<\/ol>\n\n\n\n<ol start=\"2\" class=\"wp-block-list\">\n<li>Run <code>sudo sysctl --system<\/code> and enter your password if prompted. This reloads your saved sysctl values from their config files without a reboot.<\/li>\n<\/ol>\n\n\n\n<ol start=\"3\" class=\"wp-block-list\">\n<li>Confirm forwarding is now on by running <code>cat \/proc\/sys\/net\/ipv4\/ip_forward<\/code>. A value of 1 means it\u2019s enabled, and 0 means it\u2019s still off.<\/li>\n\n\n\n<li>If your system doesn\u2019t use systemd or sysctl (e.g., WSL), set the value with <code>echo 1 | sudo tee \/proc\/sys\/net\/ipv4\/ip_forward<\/code>.<\/li>\n<\/ol>\n\n\n\n<h2 id=\"WhenShould\" class=\"wp-block-heading\">When Should You Use IP Forwarding on Linux?<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\"><strong>You\u2019ll use Linux IP forwarding whenever your machine needs to pass traffic between two or more networks on behalf of other devices.<\/strong> Here are the main cases.\u00a0<\/p>\n\n\n\n<h3 id=\"VPNServers\" class=\"wp-block-heading\">VPN Servers<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Running a VPN server requires IP forwarding. The server receives encrypted packets on the VPN tunnel interface and forwards them to the destination network through another interface. Without forwarding, the server drops those packets as they arrive.<\/p>\n\n\n\n<p class=\"wp-block-paragraph\">There\u2019s an important difference between running a server and using a VPN as a client. If you\u2019re connecting to a <a href=\"https:\/\/www.privateinternetaccess.com\/download\/linux-vpn\">VPN on your Linux device<\/a> with a client app like PIA, you don\u2019t need IP forwarding, since your machine isn\u2019t routing traffic for anyone else. It\u2019s also worth noting that IP forwarding and <a href=\"https:\/\/www.privateinternetaccess.com\/blog\/the-beginners-guide-to-vpn-port-forwarding\/\">VPN port forwarding<\/a> aren\u2019t the same thing. They sound similar but do different jobs.<\/p>\n\n\n\n<h3 id=\"h-router-or-network-gateway\" class=\"wp-block-heading\">Router or Network Gateway<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">If your Linux machine sits between multiple networks and passes traffic between them, it\u2019s effectively acting as a router. It needs IP forwarding enabled so it routes those packets instead of dropping them on arrival.<\/p>\n\n\n\n<h3 id=\"h-container-networking\" class=\"wp-block-heading\">Container Networking<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">Containerization uses platforms like Docker to package an application with everything it needs to run. Containers sometimes need to communicate with one another, and they do that over a bridge network, which relies on IP forwarding to work<sup>2<\/sup>.<\/p>\n\n\n\n<h3 id=\"h-nat-and-internet-sharing\" class=\"wp-block-heading\">NAT and Internet Sharing<\/h3>\n\n\n\n<p class=\"wp-block-paragraph\">To let several devices on a private network share one internet connection, your Linux system uses IP forwarding to act as a network address translation (NAT) device. It translates the private addresses to a single public-facing IP and forwards the packets accordingly.<\/p>\n\n\n\n<h2 id=\"LinuxIP\" class=\"wp-block-heading\">Linux IP Forwarding Risks<\/h2>\n\n\n\n<p class=\"wp-block-paragraph\">Linux IP forwarding expands what your system can do on the network, but it also creates exposure if you don\u2019t manage it carefully. The main risks include:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>Internal exposure: <\/strong>A misconfiguration can turn your Linux machine into an unintended bridge, passing traffic between your private network and the public internet. This can allow outsiders to reach systems meant to stay internal, such as private servers or admin tools. Only enable forwarding when needed and ensure it\u2019s backed by firewall rules.<\/li>\n\n\n\n<li><strong>Distributed Denial of Service (DDoS): <\/strong>Forwarding can make your device a target for <a href=\"https:\/\/www.privateinternetaccess.com\/blog\/how-to-prevent-ddos-in-gaming\/\">DDoS attacks<\/a>. If your machine is acting as a router or gateway, taking it down can knock every connected device offline. SYN floods and smurf attacks are two common examples of attacks. A well-configured <a href=\"http:\/\/www.privateinternetaccess.com\/blog\/how-does-a-firewall-work\/\">firewall<\/a> or tools that limit incoming traffic can help fend them off.<\/li>\n<\/ul>\n\n\n\n<h2 id=\"FAQ\" class=\"wp-block-heading\">FAQ<\/h2>\n\n\n\n<div class=\"schema-faq wp-block-yoast-faq-block\"><div class=\"schema-faq-section\" id=\"faq-question-1783074869041\"><h3 class=\"schema-faq-question\">What is IP forwarding in Linux?<\/h3> <p class=\"schema-faq-answer\"><a href=\"#WhatisIP\" type=\"internal\" id=\"#WhatisIP\">Linux IP forwarding is a kernel feature<\/a> that allows a Linux system to route packets between network interfaces, even when the machine itself isn\u2019t the destination. This lets it act as a router, VPN server, NAT gateway, or a Docker bridge network.<br><br><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1783075245207\"><h3 class=\"schema-faq-question\">How do I enable IP forwarding on Linux?<\/h3> <p class=\"schema-faq-answer\">You can enable IP forwarding temporarily by running <code>echo 1 | sudo tee \/proc\/sys\/net\/ipv4\/ip_forward<\/code> (for IPv4) or <code>echo 1 | sudo tee \/proc\/sys\/net\/ipv6\/conf\/all\/forwarding<\/code> (for IPv6) commands in the terminal. To make it permanent, you need to <a href=\"#Permanently\" type=\"internal\" id=\"#EnableIPForwarding\">edit the sysctl.conf file<\/a>.<br><br><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1783075260044\"><h3 class=\"schema-faq-question\">How do I enable IP forwarding on Ubuntu?<\/h3> <p class=\"schema-faq-answer\">You can temporarily enable IP forwarding on Ubuntu and other similar Linux distributions by running <code>sudo sysctl -w net.ipv4.ip_forward=1<\/code> (for IPv4) or sudo <code>sysctl -w net.ipv6.conf.all.forwarding=1<\/code> (for IPv6). To <a href=\"#Permanently\" type=\"internal\" id=\"#Permanently\">make it permanent<\/a>, uncomment the lines containing these commands in the sysctl.conf file.<br><br><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1783075275203\"><h3 class=\"schema-faq-question\">When should I use IP forwarding on a Linux server?<\/h3> <p class=\"schema-faq-answer\">You should use IP forwarding on Linux <a href=\"#WhenShould\" type=\"internal\" id=\"#WhenShould\">whenever your server needs to route traffic<\/a> for other devices, such as when it acts as a VPN server, network gateway, or NAT device.<br><br><\/p> <\/div> <div class=\"schema-faq-section\" id=\"faq-question-1783075293913\"><h3 class=\"schema-faq-question\">Can I use IP forwarding with a VPN setup for routing traffic?<\/h3> <p class=\"schema-faq-answer\">Yes. <a href=\"#VPNServers\" type=\"internal\" id=\"#VPNServers\">You\u2019ll need to enable Linux IP forwarding<\/a> when setting up a Linux machine as a VPN server. Mainstream protocols like WireGuard and OpenVPN rely on the host to forward packets between the VPN tunnel interface and external networks.<br><br><\/p> <\/div> <\/div>\n\n\n\n<p class=\"wp-block-paragraph\">References<\/p>\n\n\n\n<ol class=\"wp-block-list\">\n<li><a href=\"http:\/\/kernel.org\" type=\"link\" id=\"http:\/\/kernel.org\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">IP Sysctl \u2013 Kernel.org<\/a><\/li>\n\n\n\n<li><a href=\"https:\/\/docs.docker.com\/engine\/network\/packet-filtering-firewalls\/\" target=\"_blank\" rel=\"noreferrer noopener nofollow\">Packet filtering and firewalls \u2013 Docker<\/a><\/li>\n<\/ol>\n","protected":false},"excerpt":{"rendered":"<p>Linux IP forwarding is essential for many advanced networking tasks, but enabling it without the right configuration can create unintended security and connectivity issues. Whether you\u2019re setting up a router, gateway, VPN, or another network service in Linux, it\u2019s important to know when to enable IP forwarding, how to configure it, and when to disable &hellip; <a href=\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\" class=\"more-link\">Continue reading<span class=\"screen-reader-text\"> &#8220;Linux IP Forwarding: Complete Setup Guide&#8221;<\/span><\/a><\/p>\n","protected":false},"author":164,"featured_media":39342,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_stopmodifiedupdate":false,"_modified_date":"","footnotes":""},"categories":[1],"tags":[],"class_list":["post-39340","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-news"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v26.9 (Yoast SEO v26.9) - https:\/\/yoast.com\/product\/yoast-seo-premium-wordpress\/ -->\n<title>Linux IP Forwarding: How to Enable, Disable &amp; Configure It | PIA<\/title>\n<meta name=\"description\" content=\"Learn what Linux IP forwarding is, when to use it, and how to enable IPv4 and IPv6 forwarding on your Linux device.\" \/>\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.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Linux IP Forwarding: Complete Setup Guide\" \/>\n<meta property=\"og:description\" content=\"Learn what Linux IP forwarding is, when to use it, and how to enable IPv4 and IPv6 forwarding on your Linux device.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\" \/>\n<meta property=\"og:site_name\" content=\"PIA\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/privateinternetaccess\/\" \/>\n<meta property=\"article:published_time\" content=\"2026-07-03T10:58:04+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2026-07-03T11:05:54+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png\" \/>\n\t<meta property=\"og:image:width\" content=\"2400\" \/>\n\t<meta property=\"og:image:height\" content=\"1600\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Sue Dunham\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@buyvpnservice\" \/>\n<meta name=\"twitter:site\" content=\"@buyvpnservice\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Sue Dunham\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"9 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\"},\"author\":{\"name\":\"Sue Dunham\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/person\/2f9e53aed8eb90d48843e9425cb22dbb\"},\"headline\":\"Linux IP Forwarding: Complete Setup Guide\",\"datePublished\":\"2026-07-03T10:58:04+00:00\",\"dateModified\":\"2026-07-03T11:05:54+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\"},\"wordCount\":1664,\"publisher\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png\",\"articleSection\":[\"General Privacy News\"],\"inLanguage\":\"en-US\"},{\"@type\":[\"WebPage\",\"FAQPage\"],\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\",\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\",\"name\":\"Linux IP Forwarding: How to Enable, Disable & Configure It | PIA\",\"isPartOf\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png\",\"datePublished\":\"2026-07-03T10:58:04+00:00\",\"dateModified\":\"2026-07-03T11:05:54+00:00\",\"description\":\"Learn what Linux IP forwarding is, when to use it, and how to enable IPv4 and IPv6 forwarding on your Linux device.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#breadcrumb\"},\"mainEntity\":[{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783074869041\"},{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075245207\"},{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075260044\"},{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075275203\"},{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075293913\"}],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage\",\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png\",\"contentUrl\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png\",\"width\":2400,\"height\":1600},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.privateinternetaccess.com\/blog\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Linux IP Forwarding: Complete Setup Guide\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#website\",\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/\",\"name\":\"PIA\",\"description\":\"Online privacy news from around the world.\",\"publisher\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.privateinternetaccess.com\/blog\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#organization\",\"name\":\"Private Internet Access\",\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2018\/07\/pialogowhitekglogo.png\",\"contentUrl\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2018\/07\/pialogowhitekglogo.png\",\"width\":1200,\"height\":1200,\"caption\":\"Private Internet Access\"},\"image\":{\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/privateinternetaccess\/\",\"https:\/\/x.com\/buyvpnservice\",\"https:\/\/www.instagram.com\/piavpn\/\",\"https:\/\/www.youtube.com\/channel\/UClyJZ47Rizb1xnwuKXDI0_w\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/person\/2f9e53aed8eb90d48843e9425cb22dbb\",\"name\":\"Sue Dunham\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/cropped-image-3-96x96.png\",\"contentUrl\":\"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/cropped-image-3-96x96.png\",\"caption\":\"Sue Dunham\"},\"description\":\"Sue Dunham is a writer for the PIA blog and technophile with one goal in mind: making security simple and useful for real people. With a strong focus on VPNs, cybersecurity, and online privacy, she enjoys turning complex technical topics into clear, step-by-step guides that help readers understand not just what to do, but why it matters. When she's not writing, you'll usually find her out on a hiking trail, behind a camera, or tweaking her cyberdeck build.\",\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/author\/sue-dunham\/\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783074869041\",\"position\":1,\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783074869041\",\"name\":\"What is IP forwarding in Linux?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"<a href=\\\"#WhatisIP\\\" type=\\\"internal\\\" id=\\\"#WhatisIP\\\">Linux IP forwarding is a kernel feature<\/a> that allows a Linux system to route packets between network interfaces, even when the machine itself isn\u2019t the destination. This lets it act as a router, VPN server, NAT gateway, or a Docker bridge network.<br\/><br\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075245207\",\"position\":2,\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075245207\",\"name\":\"How do I enable IP forwarding on Linux?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"You can enable IP forwarding temporarily by running echo 1 | sudo tee \/proc\/sys\/net\/ipv4\/ip_forward (for IPv4) or echo 1 | sudo tee \/proc\/sys\/net\/ipv6\/conf\/all\/forwarding (for IPv6) commands in the terminal. To make it permanent, you need to <a href=\\\"#Permanently\\\" type=\\\"internal\\\" id=\\\"#EnableIPForwarding\\\">edit the sysctl.conf file<\/a>.<br\/><br\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075260044\",\"position\":3,\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075260044\",\"name\":\"How do I enable IP forwarding on Ubuntu?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"You can temporarily enable IP forwarding on Ubuntu and other similar Linux distributions by running sudo sysctl -w net.ipv4.ip_forward=1 (for IPv4) or sudo sysctl -w net.ipv6.conf.all.forwarding=1 (for IPv6). To <a href=\\\"#Permanently\\\" type=\\\"internal\\\" id=\\\"#Permanently\\\">make it permanent<\/a>, uncomment the lines containing these commands in the sysctl.conf file.<br\/><br\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075275203\",\"position\":4,\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075275203\",\"name\":\"When should I use IP forwarding on a Linux server?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"You should use IP forwarding on Linux <a href=\\\"#WhenShould\\\" type=\\\"internal\\\" id=\\\"#WhenShould\\\">whenever your server needs to route traffic<\/a> for other devices, such as when it acts as a VPN server, network gateway, or NAT device.<br\/><br\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"},{\"@type\":\"Question\",\"@id\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075293913\",\"position\":5,\"url\":\"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075293913\",\"name\":\"Can I use IP forwarding with a VPN setup for routing traffic?\",\"answerCount\":1,\"acceptedAnswer\":{\"@type\":\"Answer\",\"text\":\"Yes. <a href=\\\"#VPNServers\\\" type=\\\"internal\\\" id=\\\"#VPNServers\\\">You\u2019ll need to enable Linux IP forwarding<\/a> when setting up a Linux machine as a VPN server. Mainstream protocols like WireGuard and OpenVPN rely on the host to forward packets between the VPN tunnel interface and external networks.<br\/><br\/>\",\"inLanguage\":\"en-US\"},\"inLanguage\":\"en-US\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"Linux IP Forwarding: How to Enable, Disable & Configure It | PIA","description":"Learn what Linux IP forwarding is, when to use it, and how to enable IPv4 and IPv6 forwarding on your Linux device.","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.privateinternetaccess.com\/blog\/linux-ip-forwarding\/","og_locale":"en_US","og_type":"article","og_title":"Linux IP Forwarding: Complete Setup Guide","og_description":"Learn what Linux IP forwarding is, when to use it, and how to enable IPv4 and IPv6 forwarding on your Linux device.","og_url":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/","og_site_name":"PIA","article_publisher":"https:\/\/www.facebook.com\/privateinternetaccess\/","article_published_time":"2026-07-03T10:58:04+00:00","article_modified_time":"2026-07-03T11:05:54+00:00","og_image":[{"width":2400,"height":1600,"url":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png","type":"image\/png"}],"author":"Sue Dunham","twitter_card":"summary_large_image","twitter_creator":"@buyvpnservice","twitter_site":"@buyvpnservice","twitter_misc":{"Written by":"Sue Dunham","Est. reading time":"9 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#article","isPartOf":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/"},"author":{"name":"Sue Dunham","@id":"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/person\/2f9e53aed8eb90d48843e9425cb22dbb"},"headline":"Linux IP Forwarding: Complete Setup Guide","datePublished":"2026-07-03T10:58:04+00:00","dateModified":"2026-07-03T11:05:54+00:00","mainEntityOfPage":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/"},"wordCount":1664,"publisher":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/#organization"},"image":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage"},"thumbnailUrl":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png","articleSection":["General Privacy News"],"inLanguage":"en-US"},{"@type":["WebPage","FAQPage"],"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/","url":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/","name":"Linux IP Forwarding: How to Enable, Disable & Configure It | PIA","isPartOf":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage"},"image":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage"},"thumbnailUrl":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png","datePublished":"2026-07-03T10:58:04+00:00","dateModified":"2026-07-03T11:05:54+00:00","description":"Learn what Linux IP forwarding is, when to use it, and how to enable IPv4 and IPv6 forwarding on your Linux device.","breadcrumb":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#breadcrumb"},"mainEntity":[{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783074869041"},{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075245207"},{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075260044"},{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075275203"},{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075293913"}],"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#primaryimage","url":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png","contentUrl":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/featured-image-Linux-IP-Forwarding-1.png","width":2400,"height":1600},{"@type":"BreadcrumbList","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.privateinternetaccess.com\/blog\/"},{"@type":"ListItem","position":2,"name":"Linux IP Forwarding: Complete Setup Guide"}]},{"@type":"WebSite","@id":"https:\/\/www.privateinternetaccess.com\/blog\/#website","url":"https:\/\/www.privateinternetaccess.com\/blog\/","name":"PIA","description":"Online privacy news from around the world.","publisher":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.privateinternetaccess.com\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.privateinternetaccess.com\/blog\/#organization","name":"Private Internet Access","url":"https:\/\/www.privateinternetaccess.com\/blog\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2018\/07\/pialogowhitekglogo.png","contentUrl":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2018\/07\/pialogowhitekglogo.png","width":1200,"height":1200,"caption":"Private Internet Access"},"image":{"@id":"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/privateinternetaccess\/","https:\/\/x.com\/buyvpnservice","https:\/\/www.instagram.com\/piavpn\/","https:\/\/www.youtube.com\/channel\/UClyJZ47Rizb1xnwuKXDI0_w"]},{"@type":"Person","@id":"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/person\/2f9e53aed8eb90d48843e9425cb22dbb","name":"Sue Dunham","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.privateinternetaccess.com\/blog\/#\/schema\/person\/image\/","url":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/cropped-image-3-96x96.png","contentUrl":"https:\/\/www.privateinternetaccess.com\/blog\/wp-content\/uploads\/2026\/07\/cropped-image-3-96x96.png","caption":"Sue Dunham"},"description":"Sue Dunham is a writer for the PIA blog and technophile with one goal in mind: making security simple and useful for real people. With a strong focus on VPNs, cybersecurity, and online privacy, she enjoys turning complex technical topics into clear, step-by-step guides that help readers understand not just what to do, but why it matters. When she's not writing, you'll usually find her out on a hiking trail, behind a camera, or tweaking her cyberdeck build.","url":"https:\/\/www.privateinternetaccess.com\/blog\/author\/sue-dunham\/"},{"@type":"Question","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783074869041","position":1,"url":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783074869041","name":"What is IP forwarding in Linux?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"<a href=\"#WhatisIP\" type=\"internal\" id=\"#WhatisIP\">Linux IP forwarding is a kernel feature<\/a> that allows a Linux system to route packets between network interfaces, even when the machine itself isn\u2019t the destination. This lets it act as a router, VPN server, NAT gateway, or a Docker bridge network.<br\/><br\/>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075245207","position":2,"url":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075245207","name":"How do I enable IP forwarding on Linux?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"You can enable IP forwarding temporarily by running echo 1 | sudo tee \/proc\/sys\/net\/ipv4\/ip_forward (for IPv4) or echo 1 | sudo tee \/proc\/sys\/net\/ipv6\/conf\/all\/forwarding (for IPv6) commands in the terminal. To make it permanent, you need to <a href=\"#Permanently\" type=\"internal\" id=\"#EnableIPForwarding\">edit the sysctl.conf file<\/a>.<br\/><br\/>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075260044","position":3,"url":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075260044","name":"How do I enable IP forwarding on Ubuntu?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"You can temporarily enable IP forwarding on Ubuntu and other similar Linux distributions by running sudo sysctl -w net.ipv4.ip_forward=1 (for IPv4) or sudo sysctl -w net.ipv6.conf.all.forwarding=1 (for IPv6). To <a href=\"#Permanently\" type=\"internal\" id=\"#Permanently\">make it permanent<\/a>, uncomment the lines containing these commands in the sysctl.conf file.<br\/><br\/>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075275203","position":4,"url":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075275203","name":"When should I use IP forwarding on a Linux server?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"You should use IP forwarding on Linux <a href=\"#WhenShould\" type=\"internal\" id=\"#WhenShould\">whenever your server needs to route traffic<\/a> for other devices, such as when it acts as a VPN server, network gateway, or NAT device.<br\/><br\/>","inLanguage":"en-US"},"inLanguage":"en-US"},{"@type":"Question","@id":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075293913","position":5,"url":"https:\/\/www.privateinternetaccess.com\/blog\/linux-ip-forwarding\/#faq-question-1783075293913","name":"Can I use IP forwarding with a VPN setup for routing traffic?","answerCount":1,"acceptedAnswer":{"@type":"Answer","text":"Yes. <a href=\"#VPNServers\" type=\"internal\" id=\"#VPNServers\">You\u2019ll need to enable Linux IP forwarding<\/a> when setting up a Linux machine as a VPN server. Mainstream protocols like WireGuard and OpenVPN rely on the host to forward packets between the VPN tunnel interface and external networks.<br\/><br\/>","inLanguage":"en-US"},"inLanguage":"en-US"}]}},"_links":{"self":[{"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/posts\/39340","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/users\/164"}],"replies":[{"embeddable":true,"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/comments?post=39340"}],"version-history":[{"count":16,"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/posts\/39340\/revisions"}],"predecessor-version":[{"id":39374,"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/posts\/39340\/revisions\/39374"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/media\/39342"}],"wp:attachment":[{"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/media?parent=39340"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/categories?post=39340"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.privateinternetaccess.com\/blog\/wp-json\/wp\/v2\/tags?post=39340"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}