DNSMASQ

Note: in the document DNSMASQ refers to the dnsmasq scripts home directory

Summary

  • What: dnsmasq is a single package that provides PXE BOOT, DNS, DHCP services

Dependencies

  • Get the minimal PXE boot file set from ASIMOV PXEBootFilesExample
  • Get the NAT Private network MASQ firewall scripts from ASIMOV NatMasqFirewallExample
  • I Strongly suggest that you REMOVE and PURGE networkmanager and resolveconf packages!
    • apt-get remove --purge network-manager
    • apt-get remove --purge resolveconf
      • Note - side effect is that optional dns-nameserver lines in /etc/network/interfaces will be ignored - so they have to be put in /etc/resolv.conf
    • Then configure /etc/network/interfaces manually:
      • DHCP
              # This file describes the network interfaces available on your system
              # and how to activate them. For more information, see interfaces(5).
        
              # The loopback network interface
              auto lo
              iface lo inet loopback
        
              # The primary network interface
              auto eth0
              iface eth0 inet dhcp
              
      • STATIC
              # This file describes the network interfaces available on your system
              # and how to activate them. For more information, see interfaces(5).
        
              # The loopback network interface
              auto lo
              iface lo inet loopback
        
              # STATIC Configuration for eth0
              auto eth0
              iface eth0 inet static
               address 129.97.xxx.xxx
               netmask 255.255.255.0
               broadcast 129.97.xxx.255
               network 129.97.xxx.0
               gateway 129.97.xxx.1
               mtu     1492
              
      • Warnings - if your machine was imaged your network may NOT be eth0
        • Post imaging should always do a rm /etc/udev/rules.d/70-persistent-net.rules
        • So you may have to do this and reboot - only if your default is not eth0 already
        • Why? because the 70-persistent-net.rules saves the MAC address of each interface it sees so every machine a system is imaged from will increment one higher eth1,eth2 ....

Install

  • Location: asimov.uwaterloo.ca:/images/exports/dnsmasq
  • Install: rsync -a cscf-adm@asimov.uwaterloo.ca:/images/exports/dnsmasq/ /root/dnsmasq

References

Hosts using these scripts

  • asimov.cscf.uwaterloo.ca, m160.cs.uwaterloo.ca, novo1.cs.uwaterloo.ca, cabernet.cs.uwaterloo.ca husky.cs chardonnay.cs himrod.cs

Host specific configuration files

The following files are the DNSMASQ configuration files that you have to update for a new system. You will also need the dependencies listed in the previous sections

DNSMASQ/hosts.common

  • Used to help create the start section of /etc/hosts
  • Change the Head Node name your your hosts external address
  • Optionally add any address you want - but NO node addresses - that goes in DNSMASQ/dnsmasq.source.`hostname` (without the .cs or extension )
       127.0.0.1       localhost
       127.0.1.1       localhost
    
       # The following lines are desirable for IPv6 capable hosts
       ::1     localhost ip6-localhost ip6-loopback
       fe00::0 ip6-localnet
       ff00::0 ip6-mcastprefix
       ff02::1 ip6-allnodes
       ff02::2 ip6-allrouters
    
       # Backup server
       129.97.167.240 backup-0.cs.uwaterloo.ca backup-0.cs backup-0 backup.cs.uwaterloo.ca backup.cs backup
       

DNSMASQ/resolv.common

  • used to create /etc/resolv.conf - also used by Network Manager to rebuild /etc/resolv.conf
       search . cs.uwaterloo.ca uwaterloo.ca
       nameserver 127.0.0.1
       nameserver 172.19.32.5
       nameserver 172.19.32.6
       nameserver 172.19.47.6
       

DNSMASQ/dnsmasq.source.example

  • example is the name of your host
       # We turn all lines in /etc/dnsmasq.conf to comments
       # Except the line: conf-file=/etc/dnsmasq.hosts
       
       # All configuration goes here
       # ONLY the listen-address line changes when moving this to a new host
    
       # ================================================================
       include=dnsmasq.common
       # ================================================================
       # ONLY the listen-address line changes when moving this to a new host
       
       # listen-address replaced with interface for this system
       # listen-address=127.0.0.1,192.168.2.1
    
       # Private VLAN on eth1 - you can add as many as you wish
       # Example 192.168.2.1
       interface=eth1
    
       # External interface
       except-interface=eth0
       no-dhcp-interface=eth0
    
       bind-interfaces
       #This program assumes that the dhcp-range is in the following order
       # tag,min,max,ttl
       dhcp-range=comm,192.168.2.2,192.168.2.254,255.255.255.0,12h
       dhcp-option=option:router,192.168.2.1
    
       # The option numbers below conform to DHCP RFC's
       # 3 = route
       # 6 = DNS
       dhcp-option=comm,3,192.168.2.1
       # a comma separated list of DNS servers at the end of this statement
       dhcp-option=comm,6,192.168.2.1
       # ==============================================================
    
       # ==============================================================
       # Syntax:
       # IP,MAC,NAME[,CNAME]
       # subnet=192.168.8   (currently only doing /24 networks)
       # ttl=1440m   (whatever dnsmasq accepts for ttl)
       # ==============================================================
    
       # COMM
       # eth1
       ttl=1440m
       subnet=192.168.2
       # Head Node Private Network Address
       1,00:25:90:18:e2:8f,head-node
       # Nodes
       101,00:25:90:29:eb:ed,node-1,node-1-local
       102,00:25:90:29:eb:f9,node-2,node-2-local
       103,00:25:90:2b:df:71,node-3,node-3-local
       

DNSMASQ/dnsmasq.common

  • Common configuration for DNSMASQ - does not normal get changed
       resolv-file=/etc/resolv.conf
       dhcp-leasefile=/var/lib/misc/dnsmasq.leases
       local=/localnet/
       enable-tftp
       tftp-root=/tftpboot/pxes
       dhcp-boot=pxelinux.0
       dhcp-authoritative
       domain-needed
       bogus-priv
       strict-order
       

Helper scripts and programs

mkhosts and restart script

Overview

  • DNSMASQ/mkhosts: compiles simplified source file into fully qualified /etc/dnsmasq.conf file*
  • dnsmasq Provides services: * DNS * DHCP * PXE/TFTPBOOT
  • DNSMASQ/restart - master dnsmasq control script - restarts and updates all dnsmasq and related services

Makefile

  • running make compiles all configuration files and restarts dnsmasq with updated settings
  • Source files
    • DNSMASQ/hosts.common
    • DNSMASQ/dnsmasq.source.`hostname` - primary simplified source
      • DNSMASQ/dnsmasq.common - typical include file
      • /etc/resolv.conf" - created from *DNSMASQ/resolv.common
      • /etc/hostname - not updated yet
  • Services
    • DNSMASQ/Makefile - recompiles DNSMASQ/mkhosts and restarts dnsmasq
    • Adds conf-file=/etc/dnsmasq.hosts to /etc/dnsmasq.conf if it is not already there
    • Runs DNSMASQ/mkhosts -f DNSMASQ/dnsmasq.source.`hostname` -h DNSMASQ/hosts.common
    • Runs Network Manager trigger script to rebuild /etc/resolv.conf
    • Restarts dnsmasq and removes any old leases in the process
    • Restarts nscd
    • Backs up a copy of all DNSMASQ config files to *DNSMASQ/backups/`hostname`
    • Backs up a copy of all DNSMASQ related output files to *DNSMASQ/backups/`hostname`/output

mkhosts

  • DNSMASQ.mkhosts - translates simplified source file into fully qualified /etc//dnsmasq.conf include
  • Usage: DNSMASQ/mkhosts -f DNSMASQ/dnsmasq.source.`hostname` -h DNSMASQ/hosts.common
    • Output Files:
      • /etc/dnsmasq.hosts - Compiled /etc/dnsmasq.conf include file
      • /etc/hosts - Builds a /etc/hosts file from dnsmasq source files
      • /tftpboot/pxes/pxelinux.cfg/hostips - optional symlinks for per IP PXE booting
    • Source files
      • DNSMASQ/dnsmasq.source.`hostname` - Simplified dnsmasq source file
      • DNSMASQ/hosts.common - Include header for building /etc/hosts

/etc/NetworkManager/dispatcher.d/00-dnsmasq

  • Network Manager trigger script - creates /etc/resolv.conf from DNSMASQ/resolv.common

*dnsmasq.source.*=hostname= Keywords

  • ttl= time
    • time is a ttl as per the dnsmasq man pages
    • Example: ttl=1440m - set the default ttl to 1440 minutes until the next ttl keyword
  • subnet= subnet specify the subnet
    • subnet is a subnet specification - LIMITATIONS mkhosts uses hard coded /24 network - first 24 bits
    • Example: subnet=192.168.1 - this defines the subnet the same as 192.168.1.0 .. 192.168.1.255
  • ip,*mac*,*cname* [,*cname*]...
    • ip is the last digit of the subnet only
    • mac is the MAC address of the interface you want to assign the address to
    • cname a common separated list of cnames
    • Example: 101,00:25:90:29:eb:ec,m160-1-local-comm,m160-1
      • Creates
                  dhcp-host=192.168.2.101,00:25:90:29:eb:ec,m160-1-local-comm,1440m
                   ptr-record=101.2.168.192.in-addr.arpa.,"m160-1-local-comm"
                   address=/m160-1-local-comm/192.168.2.101
                   cname=m160-1,m160-1-local-comm
                 
  • prefix= We can redefine dhcp name prefix for reverse lookups
  • iface= just puts a comment in the output file
  • tag= defind tags to be appened to dhcp-host
  • pxelinux= Define the pxelinux subnet - hosts under this section can get a private boot file
    • Each mac address will simlink to the file pxelinux.cfg/nodes
  • include= process an include file

Examples

Cluster novo1.cs

  • We have three network interfaces that we want to supply DHCP,PXE BOOT, and DNS to

Source Files

DNSMASQ/mkhosts.c

DNSMASQ/Makefile

DNSMASQ/restart

DNSMASQ/dnsmasq.common

DNSMASQ/dnsmasq.source.novo1

DNSMASQ/hosts.common

DNSMASQ/resolv.common

Output Files

/etc/dnsmasq.hosts

/etc/hosts

/etc/resolv.conf

  • resolv.conf
  • Make sure you add "." to the start of the search line

/etc/dnsmasq.conf

PXE

  • PXE BOOT /tftpboot/pxes
    • Config: /tftpboot/pxes/pxelinux.cfg/default
    • ISO boot images: /tftpboot/pxes/iso

/tftpboot/pxes/pxelinux.cfg/default

Topic attachments
I Attachment Action Size Date Who Comment
Unknown file formatEXT Makefile manage 0.3 K 2012-12-21 - 10:05 MikeGore  
Unknown file formatEXT default manage 1.3 K 2012-12-21 - 10:26 MikeGore  
Unknown file formatcommon dnsmasq.common manage 0.2 K 2012-12-21 - 10:06 MikeGore  
Unknown file formatconf dnsmasq.conf manage 0.1 K 2012-12-21 - 10:12 MikeGore  
Unknown file formathosts dnsmasq.hosts manage 4.6 K 2012-12-21 - 10:25 MikeGore  
Unknown file formatm160 dnsmasq.source.m160 manage 3.2 K 2011-12-09 - 11:59 MikeGore  
Unknown file formatcs dnsmasq.source.m160.cs manage 3.7 K 2012-12-21 - 10:14 MikeGore  
Unknown file formatnovo1 dnsmasq.source.novo1 manage 2.5 K 2012-12-21 - 10:25 MikeGore  
Unknown file formatEXT hosts manage 1.7 K 2012-12-21 - 10:24 MikeGore  
Unknown file formatcommon hosts.common manage 0.3 K 2012-12-21 - 10:06 MikeGore  
C source code filec mkhosts.c manage 12.4 K 2012-12-21 - 10:17 MikeGore  
Unknown file formatcommon resolv.common manage 0.1 K 2012-12-21 - 10:06 MikeGore  
Unknown file formatconf resolv.conf manage 0.3 K 2012-12-21 - 10:25 MikeGore  
Unknown file formatEXT restart manage 3.1 K 2012-12-21 - 10:20 MikeGore  
Topic revision: r13 - 2015-08-19 - MikeGore
 
This site is powered by the TWiki collaboration platform Powered by PerlCopyright © 2008-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback