How to add a default gateway and enable IP forwarding on Ubuntu


This article show you how to add a default gateway to Ubuntu and how to enable IP forwarding. IP forwarding in this instance is also known at source NAT and allows your Ubuntu machine to act as a router.

How to add a default gateway to Ubuntu Linux

There are two possible way of doing it:

route add default gw


ip route add default via

How to Enable IP Forwarding on Ubuntu

The command to enable IP forwarding is

sudo sysctl net.ipv4.ip_forward=1

To check the setting

sudo sysctl net.ipv4.ip_forward=1



Share this article

Share on facebook
Share on twitter
Share on linkedin

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to Top