Re: [Dnsmasq-discuss] Multiple instances of dnsmasq on Debian with systemd

2018-12-03 Thread M. Buecher



On 2018-12-02 01:01, M. Buecher wrote:

I spent some time on how to keep backward compatibility for current
configurations.

The simplest solution would be to provide 2 systemd unit files:
1. An updated dnsmasq.service file for the main/default/standard
"instance", that reflects the fix for checking the configuration (see
attached file).
2. The new dnsmasq@.service file from the previous post for additional
instances.

This way nothing would change for people running just a single dnsmasq
instance. No need to rename or sym-link /etc/default/dnsmasq to
dnsmasq.main (or similar).
Still people could easily create extra instances with the new
dnsmasq@.service file and a corresponding
/etc/default/dnsmasq. file.


Got some time to look at the upstream repo.
Updated init.d script to current state plus renamed files for upstream 
repo.
# This file has six functions:
# 1) to completely disable starting this dnsmasq instance
# 2) to set DOMAIN_SUFFIX by running `dnsdomainname`
# 3) to select an alternative config file
#by setting DNSMASQ_OPTS to --conf-file=
# 4) to tell dnsmasq to read the files in /etc/dnsmasq.d for
#more configuration variables.
# 5) to stop the resolvconf package from controlling dnsmasq's
#idea of which upstream nameservers to use.
# 6) to avoid using this dnsmasq instance as the system's default resolver
#by setting DNSMASQ_EXCEPT="lo"
# For upgraders from very old versions, all the shell variables set
# here in previous versions are still honored by the init script
# so if you just keep your old version of this file nothing will break.

#DOMAIN_SUFFIX=`dnsdomainname`
#DNSMASQ_OPTS="--conf-file=/etc/dnsmasq.alt"

# Whether or not to run the dnsmasq daemon; set to 0 to disable.
ENABLED=1

# By default search this drop directory for configuration options.
# Libvirt leaves a file here to make the system dnsmasq play nice.
# Comment out this line if you don't want this. The dpkg-* are file
# endings which cause dnsmasq to skip that file. This avoids pulling
# in backups made by dpkg.
CONFIG_DIR=/etc/dnsmasq.d,.dpkg-dist,.dpkg-old,.dpkg-new

# If the resolvconf package is installed, dnsmasq will use its output
# rather than the contents of /etc/resolv.conf to find upstream
# nameservers. Uncommenting this line inhibits this behaviour.
# Note that including a "resolv-file=" line in
# /etc/dnsmasq.conf is not enough to override resolvconf if it is
# installed: the line below must be uncommented.
#IGNORE_RESOLVCONF=yes

# If the resolvconf package is installed, dnsmasq will tell resolvconf
# to use dnsmasq under 127.0.0.1 as the system's default resolver.
# Uncommenting this line inhibits this behaviour.
#DNSMASQ_EXCEPT="lo"
#!/bin/sh
### BEGIN INIT INFO
# Provides:   dnsmasq
# Required-Start: $network $remote_fs $syslog
# Required-Stop:  $network $remote_fs $syslog
# Default-Start:  2 3 4 5
# Default-Stop:   0 1 6
# Description:DHCP and DNS server
### END INIT INFO

# Don't exit on error status
set +e

PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin
DAEMON=/usr/sbin/dnsmasq
NAME=dnsmasq
DESC="DNS forwarder and DHCP server"
INSTANCE="${2}"

# Most configuration options in /etc/default/dnsmasq are deprecated
# but still honoured.
ENABLED=1
if [ -r /etc/default/${NAME}${INSTANCE:+.${INSTANCE}} ]; then
. /etc/default/${NAME}${INSTANCE:+.${INSTANCE}}
fi

# Get the system locale, so that messages are in the correct language, and the
# charset for IDN is correct
if [ -r /etc/default/locale ]; then
. /etc/default/locale
export LANG
fi

# The following test ensures the dnsmasq service is not started, when the
# package 'dnsmasq' is removed but not purged, even if the dnsmasq-base
# package is still in place.
test -e /usr/share/dnsmasq/installed-marker || exit 0

test -x ${DAEMON} || exit 0

# Provide skeleton LSB log functions for backports which don't have LSB functions.
if [ -f /lib/lsb/init-functions ]; then
. /lib/lsb/init-functions
else
log_warning_msg () {
echo "${@}."
}

log_success_msg () {
echo "${@}."
}

log_daemon_msg () {
echo -n "${1}: ${2}"
}

log_end_msg () {
if [ "${1}" -eq 0 ]; then
echo "."
elif [ "${1}" -eq 255 ]; then
/bin/echo -e " (warning)."
else
/bin/echo -e " failed!"
fi
}
fi

# RESOLV_CONF:
# If the resolvconf package is installed then use the resolv conf file
# that it provides as the default.  Otherwise use /etc/resolv.conf as
# the default.
#
# If IGNORE_RESOLVCONF is set in /etc/default/dnsmasq or an explicit
# filename is set there then this inhibits the use of the resolvconf-provided
# information.
#
# Note that if the resolvconf package is installed it is not possible to
# override it just by configuration in /etc/dnsmasq.conf, it is necessary
# to set IGNORE_RESOLVCONF=yes in /etc/default/dnsmasq.

if [ ! "${RESOLV_CONF}" ] &&
   [ "${IGNORE_RESOLVCONF}" != "yes" ] &&
   [ -x /sbin/resolvconf 

Re: [Dnsmasq-discuss] Help with dnsmasq and vlans tags

2018-12-03 Thread john doe
On 12/3/2018 4:27 PM, jmperrote wrote:
> We need help to configure dnsmasq with vlans tagged on router.
> 
> We actually have a dnsmasq server serving dns and dhcp, and 3 nics, one
> for each vlans:
> 
> dhcp-range=interface:eth0,set:VLAN_37,10.11.37.50,10.11.37.200,6h
> dhcp-option=eth0,6,10.11.37.15 #dns primario
> dhcp-option=eth0,1,255.255.255.0 # mascara de red
> dhcp-option=eth0,option:router,10.11.37.1 # gateway
> 
> dhcp-range=interface:eth0,set:VLAN_137,10.11.137.90,10.11.137.98,6h
> dhcp-option=eth0,6,10.11.37.15 #dns primario
> dhcp-option=eth0,1,255.255.255.0 # mascara de red
> dhcp-option=eth0,option:router,10.11.137.1 # gateway
> 
> dhcp-range=interface:eth0,set:VLAN_237,10.11.237.50,10.11.237.200,6h
> dhcp-option=eth0,6,10.11.37.15 #dns primario
> dhcp-option=eth0,1,255.255.255.0 # mascara de red
> dhcp-option=eth0,option:router,10.11.237.1 # gateway
> 
> 
> Know we are migratting to a dnsmasq solution with one nic a tagged
> vlans: But the result is not that we want:
> 
> We configure this:
> 
> dhcp-range=tag:vlan37,set:VLAN_37,10.11.37.50,10.11.37.200,6h
> dhcp-range=tag:vlan137,set:VLAN_137,10.11.137.50,10.11.137.200,6h
> dhcp-range=tag:vlan237,set:VLAN_237,10.11.237.50,10.11.237.200,6h
> dhcp-option=tag:vlan37,option:dns-server,10.11.37.15
> dhcp-option=tag:vlan137,option:dns-server,10.11.37.15
> dhcp-option=tag:vlan237,option:dns-server,10.11.37.15
> dhcp-option=tag:vlan137,option:router,10.11.137.1
> dhcp-option=tag:vlan37,option:router,10.11.37.1
> dhcp-option=tag:vlan237,option:router,10.11.237.1
> 
> But all clients recive allways the same gateway, 10.11.237.1
> 

I'm not sure to fully understand the issue(s) you are facing.
As far as dnsmasq is concerned, there is no differences between 3
physical "nicks" and 3 VLAN tagged interfaces  (802.1Q).
So for a start you could simply try:

# Specify DHCP range with a tag
dhcp-range=set:vlan99,172.23.100.200,172.23.100.230,12h
dhcp-range=set:vlan100,172.23.101.200,172.23.101.230,12h
dhcp-range=set:vlan100,172.23.102.200,172.23.102.230,12h

-- 
John Doe

___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss


[Dnsmasq-discuss] Help with dnsmasq and vlans tags

2018-12-03 Thread jmperrote

We need help to configure dnsmasq with vlans tagged on router.

We actually have a dnsmasq server serving dns and dhcp, and 3 nics, one 
for each vlans:


dhcp-range=interface:eth0,set:VLAN_37,10.11.37.50,10.11.37.200,6h
dhcp-option=eth0,6,10.11.37.15 #dns primario
dhcp-option=eth0,1,255.255.255.0 # mascara de red
dhcp-option=eth0,option:router,10.11.37.1 # gateway

dhcp-range=interface:eth0,set:VLAN_137,10.11.137.90,10.11.137.98,6h
dhcp-option=eth0,6,10.11.37.15 #dns primario
dhcp-option=eth0,1,255.255.255.0 # mascara de red
dhcp-option=eth0,option:router,10.11.137.1 # gateway

dhcp-range=interface:eth0,set:VLAN_237,10.11.237.50,10.11.237.200,6h
dhcp-option=eth0,6,10.11.37.15 #dns primario
dhcp-option=eth0,1,255.255.255.0 # mascara de red
dhcp-option=eth0,option:router,10.11.237.1 # gateway


Know we are migratting to a dnsmasq solution with one nic a tagged 
vlans: But the result is not that we want:


We configure this:

dhcp-range=tag:vlan37,set:VLAN_37,10.11.37.50,10.11.37.200,6h
dhcp-range=tag:vlan137,set:VLAN_137,10.11.137.50,10.11.137.200,6h
dhcp-range=tag:vlan237,set:VLAN_237,10.11.237.50,10.11.237.200,6h
dhcp-option=tag:vlan37,option:dns-server,10.11.37.15
dhcp-option=tag:vlan137,option:dns-server,10.11.37.15
dhcp-option=tag:vlan237,option:dns-server,10.11.37.15
dhcp-option=tag:vlan137,option:router,10.11.137.1
dhcp-option=tag:vlan37,option:router,10.11.37.1
dhcp-option=tag:vlan237,option:router,10.11.237.1

But all clients recive allways the same gateway, 10.11.237.1

regards.



___
Dnsmasq-discuss mailing list
Dnsmasq-discuss@lists.thekelleys.org.uk
http://lists.thekelleys.org.uk/mailman/listinfo/dnsmasq-discuss