From: Jan J. K. <ja...@ni...> - 2008-05-06 08:18:28
|
Mr Gabriel Ogunleye wrote: > My linux client does not use the DNS pushed to it from my openvpn server, but my windows client does. Any reason why the linux one works differently, I was about to roll out a linux desktop to my technical staff, but I am wondering if they will have to manually add the DNS server each time they connect. > Hi Gabriel, there are quite a few "push" and DHCP settings that are not automatically picked up by Linux clients. It is , however, quite easy to add a script that parses these settings and makes the appropriate changes to the config files. I use an 'update-dns' bash script to update the /etc/resolv.conf file whenever I connect to one of my OpenVPN servers. Add these lines to your client config files up /etc/openvpn/update-dns down /etc/openvpn/update-dns and here's the script: #!/bin/bash if [ "$script_type" = "up" ] then # cycle through foreign_option_{n} to scan for DNS servers n=1 keep_going=1 dns_list="" while [ $keep_going -eq 1 -a $n -lt 99 ] do eval option=\$foreign_option_$n if [ -n "$option" ] then # now look for "dhcp-option DNS" dns_server=${option#dhcp-option DNS } if [ ! "${option}" = "$dns_server" ] then # found one! echo " $0: DHCP pushed us nameserver $dns_server" dns_list="$dns_list\nnameserver $dns_server" fi else keep_going=0 fi let n=n+1 done # now update the list of nameservers in /etc/resolv.conf if [ -n "$dns_list" ] then echo " $0: Adding nameservers to /etc/resolv.conf" mv /etc/resolv.conf /etc/resolv.conf.pre-openvpn sed "s/^nameserver .*/$dns_list\n&/" /etc/resolv.conf.pre-openvpn > /etc/resolv.conf fi elif [ "$script_type" = "down" ] then if [ -r /etc/resolv.conf.pre-openvpn ] then echo " $0: Restoring original /etc/resolv.conf" mv /etc/resolv.conf.pre-openvpn /etc/resolv.conf fi fi HTH, JJK |