mirror of
https://github.com/pi-hole/dnsmasq.git
synced 2025-12-19 02:08:24 +00:00
import of dnsmasq-2.23.tar.gz
This commit is contained in:
22
contrib/dnsmasq_MacOSX/DNSmasq
Executable file
22
contrib/dnsmasq_MacOSX/DNSmasq
Executable file
@@ -0,0 +1,22 @@
|
||||
#!/bin/sh
|
||||
. /etc/rc.common
|
||||
|
||||
StartService() {
|
||||
if [ "${DNSMASQ:=-NO-}" = "-YES-" ] ; then
|
||||
/usr/local/sbin/dnsmasq -q -n
|
||||
fi
|
||||
}
|
||||
|
||||
StopService() {
|
||||
pid=`GetPID dnsmasq`
|
||||
if [ $? -eq 0 ]; then
|
||||
kill $pid
|
||||
fi
|
||||
}
|
||||
|
||||
RestartService() {
|
||||
StopService "$@"
|
||||
StartService "$@"
|
||||
}
|
||||
|
||||
RunService "$1"
|
||||
42
contrib/dnsmasq_MacOSX/README.rtf
Normal file
42
contrib/dnsmasq_MacOSX/README.rtf
Normal file
@@ -0,0 +1,42 @@
|
||||
{\rtf1\mac\ansicpg10000\cocoartf824\cocoasubrtf100
|
||||
{\fonttbl\f0\fswiss\fcharset77 Helvetica;\f1\fnil\fcharset77 Monaco;}
|
||||
{\colortbl;\red255\green255\blue255;}
|
||||
\paperw11900\paperh16840\margl1440\margr1440\vieww11120\viewh10100\viewkind0
|
||||
\pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\ql\qnatural\pardirnatural
|
||||
|
||||
\f0\fs24 \cf0 1. If you've used DNSenabler, or if you're using Mac OS X Server, or if you have in any other way activated Mac OS X's built-in DHCP and/or DNS servers, disable them. This would usually involve checking that they are either set to -NO- or absent altogether in
|
||||
\f1 /etc/hostconfig
|
||||
\f0 . If you've never done anything to do with DNS or DHCP servers on a client version of MacOS X, you won't need to worry about this; it will already be configured for you.\
|
||||
\
|
||||
2. Add a configuration item to
|
||||
\f1 /etc/hostconfig
|
||||
\f0 as follows:\
|
||||
\
|
||||
|
||||
\f1 DNSMASQ=-YES-
|
||||
\f0 \
|
||||
\
|
||||
3. Create a system-wide StartupItems directory for dnsmasq:\
|
||||
\
|
||||
|
||||
\f1 sudo mkdir -p /Library/StartupItems/DNSmasq\
|
||||
|
||||
\f0 \
|
||||
4. Copy the files
|
||||
\f1 DNSmasq
|
||||
\f0 and
|
||||
\f1 StartupParameters.plist
|
||||
\f0 into this directory, and make sure the former is executable:\
|
||||
\
|
||||
|
||||
\f1 sudo cp DNSmasq StartupParameters.plist /Library/StartupItems/DNSmasq\
|
||||
sudo chmod 755 /Library/StartupItems/DNSmasq/DNSmasq\
|
||||
|
||||
\f0 \
|
||||
5. Start the service:\
|
||||
\
|
||||
|
||||
\f1 sudo /Library/StartupItems/DNSmasq/DNSmasq start\
|
||||
|
||||
\f0 \cf0 \
|
||||
That should be all...}
|
||||
18
contrib/dnsmasq_MacOSX/StartupParameters.plist
Normal file
18
contrib/dnsmasq_MacOSX/StartupParameters.plist
Normal file
@@ -0,0 +1,18 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
|
||||
<plist version="1.0">
|
||||
<dict>
|
||||
<key>Description</key>
|
||||
<string>DNSmasq</string>
|
||||
<key>OrderPreference</key>
|
||||
<string>None</string>
|
||||
<key>Provides</key>
|
||||
<array>
|
||||
<string>DNSmasq</string>
|
||||
</array>
|
||||
<key>Uses</key>
|
||||
<array>
|
||||
<string>Network</string>
|
||||
</array>
|
||||
</dict>
|
||||
</plist>
|
||||
44
contrib/openvpn/README
Normal file
44
contrib/openvpn/README
Normal file
@@ -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
|
||||
>
|
||||
30
contrib/openvpn/dhclient-enter-hooks
Normal file
30
contrib/openvpn/dhclient-enter-hooks
Normal file
@@ -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
|
||||
}
|
||||
61
contrib/openvpn/dnsmasq.patch
Normal file
61
contrib/openvpn/dnsmasq.patch
Normal file
@@ -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.dhclient/' /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=$?
|
||||
Reference in New Issue
Block a user