diff options
Diffstat (limited to 'contrib/openvpn')
-rwxr-xr-x | contrib/openvpn/README | 44 | ||||
-rwxr-xr-x | contrib/openvpn/dhclient-enter-hooks | 30 | ||||
-rwxr-xr-x | contrib/openvpn/dnsmasq.patch | 61 |
3 files changed, 135 insertions, 0 deletions
diff --git a/contrib/openvpn/README b/contrib/openvpn/README new file mode 100755 index 0000000..dd99600 --- /dev/null +++ b/contrib/openvpn/README @@ -0,0 +1,44 @@ +The patch I have attached lets me get the behavior I wish out of +dnsmasq. I also include my version of dhclient-enter-hooks as +required for the switchover from pre-dnsmasq and dhclient. + +On 8/16/05, Joseph Tate <dragonstrider@gmail.com> wrote: +> I'm trying to use dnsmasq on a laptop in order to facilitate openvpn +> connections. As such, the only configuration option I'm concerned +> about is a single server=3D/example.com/192.168.0.1 line. +> +> The way I currently have it set up is I modified dhclient to write its +> resolv.conf data to /etc/resolv.conf.dhclient and configured +> /etc/dnsmasq.conf to look there for its upstream dns servers. +> /etc/resolv.conf is set to nameserver 127.0.0.1 +> +> All of this works great. When I start the openvpn service, it the +> routes, and queries to the domain in the server=3D line work just fine. +> +> The only problem is that the hostname for my system doesn't get set +> correctly. With the resolv.conf data written to something other than +> /etc/resolv.conf, the ifup scripts don't have a valid dns server to do +> the ipcalc call to set the laptop's hostname. If I start dnsmasq +> before the network comes up, something gets fubar'd. I'm not sure how +> to describe it exactly, but network services are slow to load, and +> restarting networking and dnsmasq doesn't solve the problem. Perhaps +> dnsmasq is answering the dhcp request when the network starts? +> Certainly not desired behavior. +> +> Anyway, my question: is there a way to have the best of both worlds? +> DHCP requests to another server, and DNS lookups that work at all +> times? +> +> My current best idea on how to solve this problem is modifying the +> dnsmasq initscript to tweak /etc/dhclient-enter-hooks to change where +> dhclient writes resolv.conf data, and fixing up /etc/resolv.conf on +> the fly to set 127.0.0.1 to the nameserver (and somehow keep the +> search domains intact), but I'm hoping that I'm just missing some key +> piece of the puzzle and that this problem has been solved before. Any +> insights? +> +> -- +> Joseph Tate +> Personal e-mail: jtate AT dragonstrider DOT com +> Web: http://www.dragonstrider.com +> diff --git a/contrib/openvpn/dhclient-enter-hooks b/contrib/openvpn/dhclient-enter-hooks new file mode 100755 index 0000000..cb78e2a --- /dev/null +++ b/contrib/openvpn/dhclient-enter-hooks @@ -0,0 +1,30 @@ +#!/bin/bash + +function save_previous() { + if [ -e $1 -a ! -e $1.predhclient ]; then + mv $1 $1.predhclient + fi +} + +function write_resolv_conf() { + RESOLVCONF=$1 + if [ -n "$new_domain_name" ] || [ -n "$new_domain_name_servers" ]; then + save_previous $RESOLVCONF + echo '; generated by /etc/dhclient-enter-hooks' > $RESOLVCONF + if [ -n "$SEARCH" ]; then + echo search $SEARCH >> $RESOLVCONF + else + if [ -n "$new_domain_name" ]; then + echo search $new_domain_name >> $RESOLVCONF + fi + fi + chmod 644 $RESOLVCONF + for nameserver in $new_domain_name_servers; do + echo nameserver $nameserver >>$RESOLVCONF + done + fi +} + +make_resolv_conf() { + write_resolv_conf /etc/resolv.conf +} diff --git a/contrib/openvpn/dnsmasq.patch b/contrib/openvpn/dnsmasq.patch new file mode 100755 index 0000000..5c11881 --- /dev/null +++ b/contrib/openvpn/dnsmasq.patch @@ -0,0 +1,61 @@ +--- dnsmasq-2.22/rpm/dnsmasq.rh 2005-03-24 09:51:18.000000000 -0500 ++++ dnsmasq-2.22/rpm/dnsmasq.rh.new 2005-08-25 10:52:04.310568784 -0400 +@@ -2,7 +2,7 @@ + # + # Startup script for the DNS caching server + # +-# chkconfig: 2345 99 01 ++# chkconfig: 2345 07 89 + # description: This script starts your DNS caching server + # processname: dnsmasq + # pidfile: /var/run/dnsmasq.pid +@@ -10,6 +10,25 @@ + # Source function library. + . /etc/rc.d/init.d/functions + ++function setup_dhclient_enter_hooks() { ++ if [ -f /etc/dhclient-enter-hooks ]; then ++ . /etc/dhclient-enter-hooks ++ cp /etc/resolv.conf /etc/resolv.conf.dnsmasq ++ cp /etc/dhclient-enter-hooks /etc/dhclient-enter-hooks.dnsmasq ++ sed -e 's/resolv\.conf$/resolv.conf.dnsmasq/' /etc/dhclient-enter-hooks.dnsmasq > /etc/dhclient-enter-hooks ++ sed -e 's/\(nameserver[ tab]\+\)[0-9]\+\.[0-9]\+\.[0-9]\+\.[0-9]\+$/\1127.0.0.1/' /etc/resolv.conf.dnsmasq > /etc/resolv.conf ++ fi ++} ++ ++function teardown_dhclient_enter_hooks() { ++ if [ -f /etc/dhclient-enter-hooks -a -f /etc/dhclient-enter-hooks.dnsmasq ]; then ++ if [ -f /etc/resolv.conf.dnsmasq ]; then ++ mv /etc/resolv.conf.dnsmasq /etc/resolv.conf ++ fi ++ mv /etc/dhclient-enter-hooks.dnsmasq /etc/dhclient-enter-hooks ++ fi ++} ++ + # Source networking configuration. + . /etc/sysconfig/network + +@@ -24,7 +43,7 @@ + MAILHOSTNAME="" + # change this line if you want dns to get its upstream servers from + # somewhere other that /etc/resolv.conf +-RESOLV_CONF="" ++RESOLV_CONF="/etc/resolv.conf.dnsmasq" + # change this if you want dnsmasq to cache any "hostname" or "client-hostname" from + # a dhcpd's lease file +@@ -54,6 +73,7 @@ + case "$1" in + start) + echo -n "Starting dnsmasq: " ++ setup_dhclient_enter_hooks + daemon $dnsmasq $OPTIONS + RETVAL=$? + echo +@@ -62,6 +82,7 @@ + stop) + if test "x`pidof dnsmasq`" != x; then + echo -n "Shutting down dnsmasq: " ++ teardown_dhclient_enter_hooks + killproc dnsmasq + fi + RETVAL=$? |