Last active
May 13, 2016 20:43
-
-
Save fornellas/fb911bc19f49db5a764b to your computer and use it in GitHub Desktop.
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 | |
keepalive 3 30 | |
<connection> | |
remote us.vpn.sigstop.co.uk 443 udp | |
</connection> | |
#<connection> | |
#remote us.vpn.sigstop.co.uk 443 tcp | |
#</connection> | |
resolv-retry infinite | |
persist-key | |
persist-tun | |
ca ca.crt | |
cert [client name].crt | |
key [client name].key | |
comp-lzo | |
proto tcp | |
port 443 | |
script-security 2 | |
up update-resolvconf.sh | |
down update-resolvconf.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
dev tun | |
user nobody | |
group nogroup | |
ca ca.crt | |
cert [your domain].crt | |
key [your domain].key | |
dh dh1024.pem | |
server 10.8.0.0 255.255.255.0 | |
ifconfig-pool-persist [your domain]-ipp.txt | |
push "redirect-gateway def1" | |
push "dhcp-option DNS 8.8.8.8" | |
comp-lzo | |
proto tcp | |
port 443 | |
port-share 127.0.0.1 8443 |
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 | |
set -e | |
set -o pipefail | |
IFACE="$1" | |
PROG="openvpn" | |
IFACE_PROG="${IFACE}.${PROG}" | |
function nameserver() { | |
NAMESERVERS=() | |
SEARCHES=() | |
for optionname in ${!foreign_option_*} ; do | |
option="${!optionname}" | |
part1=$(echo "$option" | cut -d " " -f 1) | |
if [ "$part1" == "dhcp-option" ] ; then | |
part2=$(echo "$option" | cut -d " " -f 2) | |
part3=$(echo "$option" | cut -d " " -f 3) | |
if [ "$part2" == "DNS" ] ; then | |
NAMESERVERS+=("$part3") | |
fi | |
if [[ "$part2" == "DOMAIN" || "$part2" == "DOMAIN-SEARCH" ]] ; then | |
SEARCHES+=("$part3") | |
fi | |
fi | |
done | |
for NAMESERVER in "${NAMESERVERS[@]}" | |
do | |
echo "nameserver $NAMESERVER" | |
done | |
for SEARCH in "${SEARCHES[@]}" | |
do | |
echo "search $SEARCH" | |
done | |
} | |
function add_resolvconf() { | |
nameserver | resolvconf -a "$IFACE_PROG" | |
} | |
function remove_resolvconf() { | |
nameserver | resolvconf -d "$IFACE_PROG" | |
} | |
case "$script_type" in | |
up) | |
add_resolvconf | |
;; | |
down) | |
remove_resolvconf | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment