Skip to content

Instantly share code, notes, and snippets.

@information-security
Created November 4, 2022 08:18
Show Gist options
  • Save information-security/9332e1af69ed1325349c5df203c86cf8 to your computer and use it in GitHub Desktop.
Save information-security/9332e1af69ed1325349c5df203c86cf8 to your computer and use it in GitHub Desktop.
Route traffic of multiple IPs through secondary gateway (e.g. ppp connections) on Ubuntu 22

Assumption

We assume that a VPN connection is already setup and a ppp0 interface is up and running.

Routing modifications

Run following commands as root user:

cd /etc/iproute2
cp rt_tables rt_tables.orig

echo "1 vpn" >> /etc/iproute2/rt_tables

ip route add default dev ppp0 table vpn

ip rule add to 44.205.64.0/24 table vpn #Docker
ip rule add to 34.205.13.0/24 table vpn # Docker
ip rule add to 3.216.34.0/24 table vpn # Docker
ip rule add to 138.197.224.240 table vpn # dist.libuv.org

Top 3 IP ranges of the above examples are for Docker to pull images through VPN connection. Docker Hub is hosted on AWS therefore these IPs might change frequently.

  • Please note that these changes are not persistent and will be lost upon system reboot.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment