Last active
July 19, 2017 09:20
-
-
Save gmvi/5fac1fa1c044f7899c97a648806316cc to your computer and use it in GitHub Desktop.
OpenVPN setup (these live in /etc/openvpn)
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
client | |
dev tun | |
proto udp | |
remote nl.privateinternetaccess.com 1194 | |
resolv-retry infinite | |
nobind | |
persist-key | |
persist-tun | |
ca /etc/openvpn/ca.crt | |
tls-client | |
remote-cert-tls server | |
auth-user-pass /etc/openvpn/login.txt | |
comp-lzo | |
verb 1 | |
reneg-sec 0 | |
crl-verify /etc/openvpn/crl.pem | |
script-security 2 | |
route-noexec | |
up /etc/openvpn/up.sh | |
down /etc/openvpn/down.sh |
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/sh | |
exit 0 |
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
[username redacted] | |
[password redacted] |
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/sh | |
echo "$dev : $ifconfig_local -> $ifconfig_remote gw: $route_vpn_gateway" | |
table_name="custom_table" | |
# make sure the ip table exists | |
if ! grep -q "^10 $table_name$" /etc/iproute2/rt_tables ; then echo "10 $table_name" >> /etc/iproute2/rt_tables; fi | |
# clear old ip rules | |
while ( ip rule del table $table_name ); do true; done | |
# write ip route and rules | |
ip route add default via $route_vpn_gateway dev $dev table $table_name | |
ip rule add from $ifconfig_local/32 table $table_name | |
ip rule add to $route_vpn_gateway/32 table $table_name | |
ip route flush cache | |
# shutdown transmission-daemon while editing the settings file | |
systemctl stop transmission-daemon | |
# TODO: replace hackey `sed` parsing with `jq` | |
sed -ri 's/(bind-address-ipv4":\s)"[^"]*"/\1"'"$ifconfig_local"'"/g' /etc/transmission-daemon/settings.json | |
systemctl start transmission-daemon | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment