]> www.infradead.org Git - users/dwmw2/vpnc-scripts.git/commitdiff
set up dnsmasq in netns
authorDavid Woodhouse <David.Woodhouse@intel.com>
Sat, 6 Jun 2009 11:55:57 +0000 (12:55 +0100)
committerDavid Woodhouse <David.Woodhouse@intel.com>
Sat, 6 Jun 2009 12:11:50 +0000 (13:11 +0100)
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
vpnc-script-sshd

index 89d7cce7ad3cec422bf8ce3895e06b6c35db71c0..971a3cf25bbffb26d0f557828d74086d85bd0ad4 100755 (executable)
@@ -174,6 +174,11 @@ function connect_parent()
     $IP addr add fec0::2/64 dev $LOCALDEV
 
     echo "VPN now accessible through 'ssh fec0::1'"
+    if ! grep -q 127.0.0.1 /etc/resolv.conf; then
+       echo "WARNING: Your host needs to be running a local dnsmasq or named"
+       echo "WARNING: and /etc/resolv.conf needs to point to 127.0.0.1"
+       # XXX: We could probably fix that for ourselves...
+    fi
 }
 
 function connect()
@@ -203,6 +208,16 @@ function connect()
     $IP link set $REMOTEDEV up
     $IP -6 addr add fec0::1/64 dev $REMOTEDEV
 
+    # Run dnsmasq to provide DNS service for this namespace.
+    # The host needs to be running its own local nameserver/dnsmasq and
+    # /etc/resolv.conf should be pointing to 127.0.0.1 already.
+    DNSMASQ_ARGS="--port=53 -k -R"
+    for NS in $INTERNAL_IP4_DNS; do 
+       DNSMASQ_ARGS="$DNSMASQ_ARGS -S $NS"
+    done
+    /usr/sbin/dnsmasq $DNSMASQ_ARGS &
+    DNSMASQ_PID=$!
+    
     # Set up sshd
     /usr/sbin/sshd -D &
     SSHD_PID=$!
@@ -214,12 +229,13 @@ function connect()
     fi
 
     # Wait for the veth link to be closed...
-    while ip link show $REMOTEDEV >/dev/null ; do
-       sleep 2
+    while ip link show $REMOTEDEV &>/dev/null ; do
+       sleep 1
     done
 
+    kill -TERM $DNSMASQ_PID
     kill -TERM $SSHD_PID
-    if [ XINETD_PID != "" ]; then
+    if [ "$XINETD_PID" != "" ]; then
        kill -TERM $XINETD_PID
     fi
     # Wait a while to avoid tun BUG() if we quit and the netns goes away