Last active
April 29, 2020 10:02
-
-
Save rohanrajpal/b443e20658cdf3e762a4e9df1a6e31bb to your computer and use it in GitHub Desktop.
Code required for selective network routing. Check out the blog https://rohanrajpal.github.io/workfromhome/vpn/networking/selective/routing/systemd/2020/04/25/Selective-network-routing.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Whitelist here all domains that need to go through openfortivpn | |
# Domains and IPs are separated by a space | |
# | |
ips='192.168.2.217 192.168.29.151' | |
domains='example.com example.fr' | |
let resolved | |
for domain in $domains; do | |
resolved=`dig +short $domain | tail -n1` | |
ips="$ips $resolved" | |
done | |
for ip in $ips; do | |
route add $ip dev ppp0 | |
done |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[Unit] | |
Description = OpenFortiVPN | |
After=network-online.target | |
Documentation=man:openfortivpn(1) | |
[Service] | |
Type=idle | |
ExecStart = /usr/bin/openfortivpn -c <path to your config file> | |
StandardOutput=file:<any-place-where you want to save your logs> | |
Restart=always | |
RestartSec=10 | |
[Install] | |
WantedBy=multi-user.target |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
host = vpn.iiitd.edu.in | |
port = 10443 | |
username = <your username> | |
password = <your pass> | |
set-routes = 0 | |
set-dns = 0 | |
pppd-use-peerdns = 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment