tonywhitmore.co.uk  

      blog : gallery : wiki : articles : projects : shell scripts : wallpaper : cv : links :
 Project Homepage

DNSMasq

Preparation

  1. Download the DNSMasq source code from www.thekelleys.org.uk/dnsmasq/.
    • Visit www.thekelleys.org.uk/dnsmasq/ and click on the link for the latest version of DNSMasq. You will need the source code in .tar.gz format.
      • At the time of writing the latest version of DNSMasq was version 1.10, so the file downloaded was dnsmasq-1.10.tar.gz.
    • You will be asked to where you wish to save the file. Chose a safe place and make a note of it.
    • The download is about 51kb and will only take a few seconds to download.
    • If you are using a download accelerator program, it will save the file to your default download directory.
    • Burn the file dnsmasq-1.10.tar.gz to a CD. This page assumes that the subdirectory /apps is used for the .tar.gz file. The CD-ROM can be a multi-session disk.
      • Use your CD burning software to create an ISO9660 disc image with the file dnsmasq-1.10.tar.gz in the /apps directory.
      • Burn the CD and verify the data stored on it.

Back to simple version

Booting

  1. Boot your Core Linux PC.
  2. Login as root. You will need to enter the password at the prompt.
    • Wait for the following text to appear:
      localhost login:
    • Type root and press Enter.
    • The screen will display this message:
      Password:
    • Enter the password for root that you set earlier.
    • You will be shown a prompt that looks like this:
      [~]#

Back to simple version

Extract the source

  1. Place the CD-R in the CD-ROM drive. Mount the CD-ROM drive under /mnt/cdrom.
    • At the prompt enter:
      mount /dev/hdb /mnt/cdrom
    • You will see the following line appear:
      mount: block device /dev/hdb is write-protected, mounting read-only
  2. Change to the /apps directory on the CD-R.
    • At the prompt enter:
      cd /mnt/cdrom/apps
    • The prompt will change to:
      [/mnt/cdrom/apps]#
  3. Copy the dnsmasq-1.10.tar.gz file to the directory /usr/src.
    • At the prompt enter:
      cp dnsmasq-1.10.tar.gz /usr/src
    • The system will not display a message if everything is OK.
  4. Change to the /usr/src directory and extract the source from the .tar.gz file.
    • At the prompt enter:
      cd /usr/src
    • The prompt will change to:
      [/usr/src]#
    • At the prompt enter:
      tar -zxvf dnsmasq-1.10.tar.gz
    • A long stream of unzipping files and directories should scroll up the screen for a few seconds.

Back to simple version

Configure and compile

  1. Change to the /usr/src/dnsmasq-1.10 directory.
    • At the prompt enter:
      cd dnsmasq-1.10
    • The prompt will change to:
      [/usr/src/dnsmasq-1.10]#
  2. Run the make program with the argument install.
    • At the prompt enter:
      make install
    • A long stream of processes should scroll up the screen for a few seconds.
    • The program finishes with the line:
      install -m 755 dnsmasq /usr/local/sbin

Back to simple version

Testing

  1. Configure the upstream DNS servers for your Core Linux system.
    • Configuration of network settings for Core Linux was covered here.
  2. Add the user nobody.
    • At the system prompt enter:
      useradd nobody
    • The system will not display a message if everything is OK.
  3. Start the DNSMasq daemon using /usr/local/sbin/dnsmasq --log-queries.
    • At the prompt enter:
      /usr/local/sbin/dnsmasq --log-queries
    • The system will not display a message if everything is OK.
  4. Set your other computer to use your Core Linux system as its only DNS server.
    • How you do this will depend on your operating system and whether you use DHCP on your network.
  5. Make a DNS lookup from the client computer (e.g. try to open a web page in a web browser using its domain name).
  6. Check logs on your Core Linux system to ensure that DNSMasq performed the query correctly.
    • On your Core Linux system enter:
      cat /var/log/syslog | tail
    • If the query successfully used DNSMasq rather than any other DNS server, you will see information reflecting your lookup:
      Jan 12 12:26:50 localhost dnsmasq[114]: reply www.google.com is 216.239.33.101

Back to simple version

Automating DNSMasq

  1. Append the following line to the /etc/rc.d/rc.mu script:
    /usr/local/sbin/dnsmasq -q
    You should adjust the above line to reflect the options with which you want DNSMasq to run. You can also add comments and echoes for your own information.
    • At the prompt enter:
      nano /etc/rc.d/rc.mu
    • The screen will show the contents of /etc/rc.d/rc.mu with information about the file at the top and bottom of the screen.
    • Add the following text to the end of the file:
      # Start DNSMasq
      /usr/local/sbin/dnsmasq -q
      echo DNSMasq Started
    • Save the file and exit the text editor.
      • Press Ctrl+x on the keyboard.
      • The contents of the white line at the bottom of the screen will change to read:
        Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
      • Type y.
      • The contents of the white line at the bottom of the screen will change to read:
        File Name to write: /etc/rc.d/rc.mu
      • Press Enter.
      • You will be returned to the system prompt.
  2. Insert the following line at the second line of the /etc/rc.d/rc.rb script:
    kill `cat /var/run/dnsmasq.pid`
    You can also add comments and echoes for your own information.
    • At the prompt enter:
      nano /etc/rc.d/rc.rb
    • The screen will show the contents of /etc/rc.d/rc.rb with information about the file at the top and bottom of the screen.
    • Insert the following text at the second line of the file:
      # Stop DNSMasq
      kill `cat /var/run/dnsmasq.pid`
      echo DNSMasq Stopped
    • Save the file and exit the text editor.
      • Press Ctrl+x on the keyboard.
      • The contents of the white line at the bottom of the screen will change to read:
        Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
      • Type y.
      • The contents of the white line at the bottom of the screen will change to read:
        File Name to write: /etc/rc.d/rc.rb
      • Press Enter.
      • You will be returned to the system prompt.
  3. Insert the following line at the second line of the /etc/rc.d/rc.ha script:
    kill `cat /var/run/dnsmasq.pid`
    You can also add comments and echoes for your own information.
    • At the prompt enter:
      nano /etc/rc.d/rc.ha
    • The screen will show the contents of /etc/rc.d/rc.ha with information about the file at the top and bottom of the screen.
    • Insert the following text at the second line of the file:
      # Stop DNSMasq
      kill `cat /var/run/dnsmasq.pid`
      echo DNSMasq Stopped
    • Save the file and exit the text editor.
      • Press Ctrl+x on the keyboard.
      • The contents of the white line at the bottom of the screen will change to read:
        Save modified buffer (ANSWERING "No" WILL DESTROY CHANGES) ?
      • Type y.
      • The contents of the white line at the bottom of the screen will change to read:
        File Name to write: /etc/rc.d/rc.ha
      • Press Enter.
      • You will be returned to the system prompt.
  4. Reboot the system and check that DNSMasq is running.
    • At the system prompt enter:
      shutdown -r now
    • Wait for the system to reboot.
    • As the system reboots, watch for any error messages.
    • Once the system has rebooted, try to perform a DNS lookup on your other PC.

Back to simple version

Creative Commons License
The text of this page is licensed under a Creative Commons License.


Valid CSS!     Valid HTML 4.0!     Valid RSS
Original design © For oswd.org by SquireCD