Advertisement
jdefelice

.vpn/up

Sep 22nd, 2012
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.60 KB | None | 0 0
  1. #!/bin/bash
  2. # script to automatically set DNS information on connection
  3.  
  4. mv -v /etc/resolv.conf /etc/resolv.conf.hold # back up old file
  5.  
  6. for OPTION in ${!foreign_option_*} ;
  7. do
  8.         [ -z "${!OPTION}" ] && break
  9.         if [ -n "$(echo ${!OPTION} | egrep -e '^dhcp-option (DOMAIN|DNS)')" ]; then
  10.                 echo ${!OPTION} | sed \
  11.             -e 's/dhcp-option DOMAIN/search/g' \
  12.             -e 's/dhcp-option DNS/nameserver/g' \
  13.             >> /etc/resolv.conf
  14.         fi
  15. done
  16.  
  17. if [ ! -f /etc/resolv.conf ]; then # openvpn did not set any DNS information
  18.         mv -v /etc/resolv.conf.hold /etc/resolv.conf
  19. fi
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement