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


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


  • 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
               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 ....


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


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


  • 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 )       localhost       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 backup-0.cs.uwaterloo.ca backup-0.cs backup-0 backup.cs.uwaterloo.ca backup.cs backup


  • used to create /etc/resolv.conf - also used by Network Manager to rebuild /etc/resolv.conf
       search . cs.uwaterloo.ca uwaterloo.ca


  • 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
       # ================================================================
       # ================================================================
       # ONLY the listen-address line changes when moving this to a new host
       # listen-address replaced with interface for this system
       # listen-address=,
       # Private VLAN on eth1 - you can add as many as you wish
       # Example
       # External interface
       #This program assumes that the dhcp-range is in the following order
       # tag,min,max,ttl
       # The option numbers below conform to DHCP RFC's
       # 3 = route
       # 6 = DNS
       # a comma separated list of DNS servers at the end of this statement
       # ==============================================================
       # ==============================================================
       # Syntax:
       # IP,MAC,NAME[,CNAME]
       # subnet=192.168.8   (currently only doing /24 networks)
       # ttl=1440m   (whatever dnsmasq accepts for ttl)
       # ==============================================================
       # COMM
       # eth1
       # Head Node Private Network Address
       # Nodes


  • Common configuration for DNSMASQ - does not normal get changed

Helper scripts and programs

mkhosts and restart script


  • 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


  • 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


  • 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


  • 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 ..
  • 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
  • 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


Cluster novo1.cs

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

Source Files








Output Files




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



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


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-2015 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback

mersin escort bayan adana escort bayan izmit escort ankara escort bursa escort