Created
March 24, 2012 12:41
-
-
Save Hexcles/2182248 to your computer and use it in GitHub Desktop.
Setting up DNS according to OpenVPN dhcp-option (used with openvpn --up)
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 | |
# Setting up DNS according to OpenVPN dhcp-option | |
# used with openvpn --up | |
mv /etc/resolv.conf /etc/resolv.conf.old | |
for (( i=1; 1; i++)) | |
do | |
optname="foreign_option_$i" | |
option=${!optname} | |
[ -n "$option" ] || break | |
if [ -n `echo $option | grep DOMAIN` ] || [ -n `echo $option | grep DNS` ] | |
then | |
echo $option | sed -e 's/dhcp-option DOMAIN/search/g' -e 's/dhcp-option DNS/nameserver/g' >> /etc/resolv.conf | |
fi | |
done | |
if [ -f /etc/resolv.conf ] | |
then | |
cat /etc/resolv.conf | |
else | |
mv /etc/resolv.conf.old /etc/resolv.conf | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment