Summary
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
Here are two possible way of doing it.
The first one is more native and will be available on most Debian based systems. The second one might need to have a specific library installed.
ip route add default via 192.168.56.1
or
route add default gw 192.168.56.1
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
References
- https://linuxhint.com/set-default-gateway-ubuntu/
- https://www.cyberciti.biz/faq/howto-debian-ubutnu-set-default-gateway-ipaddress/
- http://www.networkinghowtos.com/howto/enable-ip-forwarding-on-ubuntu-13-04/