Created
August 19, 2013 21:10
-
-
Save iMilnb/6274243 to your computer and use it in GitHub Desktop.
Update OpenVPN remotes for vpntunnel endpoints with IP addresses instead of FQDN as resolving fails from time to time
This file contains hidden or 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 | |
[ $# -lt 1 ] && exit 1 | |
tunnel="jenny.vpntunnel.se" | |
ovpntmp="/tmp/openvpn.conf-tmp" | |
ovpncnf=$1 | |
host -t a ${tunnel} >/dev/null 2>&1 || exit 1 | |
sed '/^remote\ /d' "${ovpncnf}" > "${ovpntmp}" | |
for ip in `host -t a ${tunnel}|grep -oE [0-9\.]+$` | |
do | |
for port in `seq 7001 7004` | |
do | |
echo remote ${ip} ${port} >> "${ovpntmp}" | |
done | |
done | |
cp -f "${ovpntmp}" "${ovpncnf}" | |
kill -HUP `cat /var/run/openvpn.pid` |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment