Ubuntu: Route Traffic Through VPN Tunnel

enp2s0 outisde interface
enp2s0:1 outside interface with Internet
tun0: VPN Tunnel

Edit /etc/sysctl.conf

sudo nano /etc/sysctl.conf

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1

Edit /etc/default/ufw

sudo nano /etc/default/ufw

# Set the default forward policy to ACCEPT, DROP or REJECT.  Please note that
# if you change this you will most likely want to adjust your rules
DEFAULT_FORWARD_POLICY="ACCEPT"

UFW
/etc/ufw/sysctl.conf

sudo nano /etc/ufw/sysctl.conf

# Uncomment the next line to enable packet forwarding for IPv4
net.ipv4.ip_forward=1
sudo ufw allow 22
sudo ufw route allow in on enp2s0 out on tun0 to any from any

Reference:

https://askubuntu.com/questions/703896/forward-only-web-traffic-to-another-interface

Configuring iptables on Ubuntu 14.04


https://gist.github.com/kimus/9315140
https://stackoverflow.com/questions/3742983/how-to-get-the-contents-of-a-webpage-in-a-shell-variable

Comments are closed