LinuxQuestions.org
Support LQ: Use code LQ3 and save $3 on Domain Registration
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Distributions > Slackware
User Name
Password
Slackware This Forum is for the discussion of Slackware Linux.

Notices

Reply
 
Search this Thread
Old 03-16-2014, 05:45 AM   #1
kikinovak
Senior Member
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: ElementaryOS, Ubuntu LTS, Slackware
Posts: 1,550

Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Replace dhcpd+bind by dnsmasq in a local network: few details


Hi,

In my local network (and on client's LANs), I'm using dhcpd and Bind to manage DHCP and DNS services. I've been reading some Dnsmasq documentation lately, and I think this would be a more simple solution, the more so since Dnsmasq is already shipping with a stock Slackware installation and its syntax seems more straightforward. I've experimented with it for a few hours, and first results are encouraging. There are a few configuration details that I have yet to solve.

Here's my current setup.

1. DHCP server:

Code:
# /etc/dhcpd.conf
authoritative;
default-lease-time 86400;
max-lease-time 86400;
option broadcast-address 192.168.2.255;
option subnet-mask 255.255.255.0;
option routers 192.168.2.1;
option domain-name-servers 192.168.2.1;
option domain-name "microlinux.montpezat";
option domain-search "microlinux.montpezat";

subnet 192.168.2.0 netmask 255.255.255.0 {
        range 192.168.2.100 192.168.2.200;
}

host alphamule {
        hardware ethernet 00:1F:D0:AE:EC:FE;
        fixed-address 192.168.2.2;
        option host-name "alphamule";
}

host bernadette {
        hardware ethernet 00:1D:09:15:4A:D8;
        fixed-address 192.168.2.3;
        option host-name "bernadette";
}

host raymonde {
        hardware ethernet 00:1E:C9:43:A7:BF;
        fixed-address 192.168.2.4;
        option host-name "raymonde";
}

host amandine {
        hardware ethernet 00:30:F1:6A:2F:40;
        fixed-address 192.168.2.5;
        option host-name "amandine";
}

host buzz-wired {
  hardware ethernet 44:1E:A1:E6:FA:93;
  fixed-address 192.168.2.6;
  option host-name "buzz";
}

host buzz-wireless {
  hardware ethernet E4:D5:3D:BD:EA:05;
  fixed-address 192.168.2.6;
  option host-name "buzz";
}

host bebette-wired {
  hardware ethernet 00:27:19:F1:BC:3A;
  fixed-address 192.168.2.7;
  option host-name "bebette";
}

host bebette-wireless {
  hardware ethernet 00:19:E0:83:3A:C1;
  fixed-address 192.168.2.7;
  option host-name "bebette";
}

host buildbox {
        hardware ethernet 08:00:27:16:55:96;
        fixed-address 192.168.2.8;
        option host-name "buildbox";
}
2. Bind configuration:

Code:
// /etc/named.conf
options {
        directory "/var/named";
        query-source address * port 53;
  forwarders {
  // DNS 1 Nerim
  // 195.5.209.150;
  // DNS 2 Nerim
  // 194.79.128.150;
  // DNS 1 Google
  8.8.8.8;
  // DNS 2 Google
  8.8.4.4;
  };
};

// 
// a caching only nameserver config
// 
zone "." IN {
        type hint;
        file "named.root";
};

zone "localhost" IN {
        type master;
        file "localhost.zone";
        allow-update { none; };
};

zone "0.0.127.in-addr.arpa" IN {
        type master;
        file "named.local";
        allow-update { none; };
};

zone "microlinux.montpezat" {
  type master;
  file "/var/named/zone.microlinux.montpezat";
};

zone "2.168.192.in-addr.arpa" { 
  type master; 
  file "/var/named/revp.192.168.2"; 
};
Code:
; zone.microlinux.montpezat
$TTL 86400
$ORIGIN microlinux.montpezat.
@ IN SOA nestor.microlinux.montpezat. hostmaster.microlinux.montpezat. (
    70         ; serial 
    3H         ; refresh
    15M        ; retry
    1W         ; expiry
    1D )       ; minimum
                         IN NS nestor.microlinux.montpezat.
                         IN MX 10 mail.microlinux.montpezat.
nestor                   IN A 192.168.2.1
alphamule                IN A 192.168.2.2
bernadette               IN A 192.168.2.3
raymonde                 IN A 192.168.2.4
amandine                 IN A 192.168.2.5
buzz                     IN A 192.168.2.6
bebette                  IN A 192.168.2.7
buildbox                 IN A 192.168.2.7
wireless-ap              IN A 192.168.2.254

; Sites hébergés sur Nestor
mirror.nestor            IN A 192.168.2.1
cmsms.nestor             IN A 192.168.2.1
dan-services.nestor      IN A 192.168.2.1
dolibarr.nestor          IN A 192.168.2.1
fuckmicrosoft.nestor     IN A 192.168.2.1
gepi.nestor              IN A 192.168.2.1
kikinovak.nestor         IN A 192.168.2.1
microlinux.nestor        IN A 192.168.2.1
microlinux-2010.nestor   IN A 192.168.2.1
microlinux-2011.nestor   IN A 192.168.2.1
microlinux-2012.nestor   IN A 192.168.2.1
microlinux-2013.nestor   IN A 192.168.2.1
newscholae.nestor        IN A 192.168.2.1
osteo.nestor             IN A 192.168.2.1
osteo-montpellier.nestor IN A 192.168.2.1
osteo-sommieres.nestor   IN A 192.168.2.1
phpinfo.nestor           IN A 192.168.2.1
radionovak.nestor        IN A 192.168.2.1
scholae.nestor           IN A 192.168.2.1
scholaecms.nestor        IN A 192.168.2.1
villa-figaret.nestor     IN A 192.168.2.1
Code:
; revp.192.168.2 
$ORIGIN 2.168.192.in-addr.arpa.
$TTL 86400
@ IN SOA nestor.microlinux.montpezat. hostmaster.microlinux.montpezat. (
    70         ; serial
    3H         ; refresh 
    15M        ; retry 
    1W         ; expiry 
    1D )       ; minimum 
    IN NS  nestor.microlinux.montpezat.
1   IN PTR nestor.microlinux.montpezat.
2   IN PTR alphamule.microlinux.montpezat.
3   IN PTR bernadette.microlinux.montpezat.
4   IN PTR raymonde.microlinux.montpezat.
5   IN PTR amandine.microlinux.montpezat.
6   IN PTR buzz.microlinux.montpezat.
7   IN PTR bebette.microlinux.montpezat.
8   IN PTR buildbox.microlinux.montpezat.
254 IN PTR wireless-ap.microlinux.montpezat.
Now here's what my Dnsmasq configuration looks like for the moment:

Code:
# /etc/dnsmasq.conf
domain-needed
bogus-priv
interface=eth1
dhcp-range=192.168.2.100,192.168.2.200,24h
local=/microlinux.montpezat/
domain=microlinux.montpezat
expand-hosts
server=8.8.8.8
server=8.8.4.4
dhcp-host=00:1F:D0:AE:EC:FE,alphamule,192.168.2.2
dhcp-host=00:1D:09:15:4A:D8,bernadette,192.168.2.3
dhcp-host=00:1E:C9:43:A7:BF,raymonde,192.168.2.4
dhcp-host=00:30:F1:6A:2F:40,amandine,192.168.2.5
dhcp-host=44:1E:A1:E6:FA:93,E4:D5:3D:BD:EA:05,buzz,192.168.2.6
dhcp-host=00:27:19:F1:BC:3A,00:19:E0:83:3A:C1,bebette,192.168.2.7
dhcp-host=08:00:27:16:55:96,buildbox,192.168.2.8
So far, the setup works as expected. Hostnames are managed centrally on the server, e. g. client machines don't have any hostname configuration in their /etc/HOSTNAME or /etc/hosts.

There's a few things I have yet to figure out. First things first. How do I add additional DNS entries like those in /var/named/zone.microlinux.montpezat?

Code:
mirror.nestor            IN A 192.168.2.1
cmsms.nestor             IN A 192.168.2.1
dan-services.nestor      IN A 192.168.2.1
One other thing: as far as I can tell, dnsmasq works like dhcpd and bind, e. g. uses UDP port 67 as well as TCP and UDP port 53 for managing DHCP and DNS requests. Right?

Cheers,

Niki

Last edited by kikinovak; 03-16-2014 at 05:47 AM.
 
Old 03-16-2014, 06:15 AM   #2
kikinovak
Senior Member
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: ElementaryOS, Ubuntu LTS, Slackware
Posts: 1,550

Original Poster
Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
I try to answer the first question myself. After some more experimenting, I tried the following directive:

Code:
# /etc/dnsmasq.conf
...
address=/mirror.nestor/192.168.2.1
address=/cmsms.nestor/192.168.2.1
...
I don't know if this solution is orthodox, but so far, it seems to work.

Any suggestions, in general and in particular?
 
Old 03-16-2014, 06:34 AM   #3
Alien Bob
Slackware Contributor
 
Registered: Sep 2005
Location: Eindhoven, The Netherlands
Distribution: Slackware
Posts: 5,234

Rep: Reputation: Disabled
Officially, your use of the "address" is incorrect - the "address" statement is used to mask a whole domain behind a single IP address. In your case, "mirror.nestor" is seen by dnsmasq as a domain name, not a host name. If you look up anything ending on "mirror.nestor", like one.mirror.nestor , foo.mirror.nestor but also just mirror.nestor, dnsmasq will return 192.168.2.1. Effectively, this does what you want.

The correct way of adding hosts is to write them into your server's /etc/hosts file.

Eric
 
2 members found this post helpful.
Old 03-16-2014, 08:10 AM   #4
Mark Pettit
Member
 
Registered: Dec 2008
Location: Cape Town, South Africa
Distribution: Slackware 14.1 64 Multi-Lib
Posts: 425

Rep: Reputation: 123Reputation: 123
The entries below are from my own home server conf file - they may be of some use to you ...

#dhcp-option= options from rfc2132
dhcp-option=1,255.255.255.0
dhcp-option=3,192.168.24.100 # router option, fix when this machine dials out
dhcp-option=4,192.168.24.100 # time server is option 4
dhcp-option=5,192.168.24.100 # name server is option 5
dhcp-option=6,192.168.24.100 # dns option
dhcp-option=19,0 # ip forwarding off
dhcp-option=42,192.168.24.100 # ntp server is option 42
dhcp-option=44,192.168.24.100 # netbios over tcp/ip name server
dhcp-option=45,192.168.24.100 # netbios over tcp/ip datagram distribution server option
dhcp-option=46,8 # netbios over tcp/ip node type option
dhcp-option=47 # netbios over tcp/ip scope option
dhcp-option=252,"\n" # Send an empty WPAD option. This may be REQUIRED to get windows 7 to behave.
 
1 members found this post helpful.
Old 03-16-2014, 11:51 AM   #5
kikinovak
Senior Member
 
Registered: Jun 2011
Location: Montpezat (South France)
Distribution: ElementaryOS, Ubuntu LTS, Slackware
Posts: 1,550

Original Poster
Rep: Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721Reputation: 721
Quote:
Originally Posted by Alien Bob View Post
Officially, your use of the "address" is incorrect - the "address" statement is used to mask a whole domain behind a single IP address. In your case, "mirror.nestor" is seen by dnsmasq as a domain name, not a host name. If you look up anything ending on "mirror.nestor", like one.mirror.nestor , foo.mirror.nestor but also just mirror.nestor, dnsmasq will return 192.168.2.1. Effectively, this does what you want.

The correct way of adding hosts is to write them into your server's /etc/hosts file.

Eric
I forgot to mention it, but I think you guessed it so far. The local server is also running a LAMP server, and all these mirror.nestor, cmsms.nestor etc. entries are so many Apache virtual hosts. So in other terms, it's sufficient to add them to the server's /etc/hosts... and then Dnsmasq takes care of "propagating" this information to the local network's clients?

Edit: looks like this works indeed as announced. Thanks very much, Eric!

Last edited by kikinovak; 03-16-2014 at 11:56 AM.
 
Old 03-16-2014, 05:44 PM   #6
allend
Senior Member
 
Registered: Oct 2003
Location: Melbourne
Distribution: Slackware-current
Posts: 3,408

Rep: Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835Reputation: 835
Quote:
dhcp-option=252,"\n" # Send an empty WPAD option. This may be REQUIRED to get windows 7 to behave
I just found this one recently. It stops annoying log spam from Windows 7 machines continually seeking a WPAD server.
 
  


Reply

Tags
dhcp, dns, dnsmasq


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
bind or dnsmasq ? !! hack-back !! Linux - Networking 6 02-04-2013 06:05 AM
[SOLVED] Bind on local network: can't do short hostname and reverse lookups kikinovak Slackware 3 12-08-2012 06:54 AM
BIND (local DNS), network unreachable resolving, IPv4 davidlt Debian 2 02-17-2011 02:42 PM
dnsmasq as a replacement for BIND alex23 Linux - Networking 1 04-23-2009 01:51 PM
BIND for local domain for small network jst1 Linux - Server 2 04-04-2008 09:59 AM


All times are GMT -5. The time now is 03:48 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration