🔄 How to Enable IP Forwarding on Debian 12 (Bookworm) 🚀


If you’re setting up a router, a VPN gateway, or just need your Debian 12 (Bookworm) machine to forward packets between interfaces, you’ll need to enable IP forwarding.
By default, Debian does not forward packets, but enabling it is straightforward. Let’s dive in! 🏊♂️
🛠 Step 1: Temporarily Enable IP Forwarding
If you want to enable IPv4 forwarding for the current session (without making it permanent), run:
sudo sysctl -w net.ipv4.ip_forward=1
🔹 Note: These changes will disappear after a reboot! To make them permanent, proceed to Step 2.
📄 Step 2: Make IP Forwarding Permanent
To ensure IP forwarding is always enabled after reboots, we modify the sysctl configuration file.
🔧 Enable IPv4 Forwarding Permanently
1️⃣ Open the sysctl configuration file:
sudo nano /etc/sysctl.conf
2️⃣ Find this line (or add it if it doesn’t exist):
net.ipv4.ip_forward=1
net.netfilter.nf_conntrack_max=1048576
3️⃣ Save the file (Ctrl + X
, then Y
, then Enter
).
🔄 Step 3: Apply Changes Without Rebooting
Instead of restarting the system, apply the new settings immediately:
sudo sysctl -p
🔥 Step 4: Verify That Forwarding is Enabled
You can check if forwarding is active using:
cat /proc/sys/net/ipv4/ip_forward
It should return 1 if enabled.
🛡 Step 5: Adjust Firewall Rules (If Needed)
If you’re using nftables, ensure your firewall allows forwarding.
For nftables, use something like:
nft add rule ip filter forward accept
✅ Wrap
That’s it! 🎉 Your Debian 12 (Bookworm) machine is now forwarding packets like a pro. 🚀 Whether you’re setting up a router, VPN gateway, or multi-interface server, you’re good to go!
Happy networking! 🌐🔥
Subscribe to my newsletter
Read articles from Ronald Bartels directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by

Ronald Bartels
Ronald Bartels
Driving SD-WAN Adoption in South Africa