LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 04-06-2012, 02:06 AM   #1
samopal
LQ Newbie
 
Registered: Aug 2007
Posts: 14

Rep: Reputation: 0
Question DHCP server for small lan


Dear community,

I've got a big multi-purpose server where Ubuntu 11.04 is running. I've made a basic dhcp server based on the official documentation.
Code:
authoritative; 
default-lease-time 21600;
max-lease-time 21600;
INTERFACES="eth1"; 

subnet 192.168.1.0 netmask 255.255.255.0 {
 interface eth1;
 range 192.168.1.10 192.168.1.90;
 option routers 192.168.1.1;
 option broadcast-address 192.168.1.255;
 option domain-name-servers 192.168.1.1;
 option subnet-mask 255.255.255.0;
} 

# host hp-server { hardware ethernet 00:1C:C4:96:5C:38; fixed-address 192.168.1.9;}

# zberne dat 
host zber01 { hardware ethernet 00:1B:EB:20:2D:38; fixed-address 192.168.1.121; } 
host zber02 { hardware ethernet 00:1B:EB:21:18:1F; fixed-address 192.168.1.122; } 
host zber03 { hardware ethernet 00:1B:EB:35:12:6A; fixed-address 192.168.1.123; } 
host zber04 { hardware ethernet 00:1B:EB:21:18:1A; fixed-address 192.168.1.124; } 
#host zber05 { hardware ethernet xxxmac; fixed-address 192.168.1.125; } 
#host zber06 { hardware ethernet xxxmac; fixed-address 192.168.1.126; } 
#host zber07 { hardware ethernet xxxmac; fixed-address 192.168.1.127; } 
#host zber08 { hardware ethernet xxxmac; fixed-address 192.168.1.128; } 

# pouzivatelia 
host user1 { hardware ethernet 00:19:DB:D2:7D:93; fixed-address 192.168.1.150;}
host user2 { hardware ethernet C4:17:FE:02:60:19; fixed-address 192.168.1.151;}
host user3 { hardware ethernet 50:E5:49:27:86:B3; fixed-address 192.168.1.152;}
host user4 { hardware ethernet F4:CE:46:F0:E8:7D; fixed-address 192.168.1.153; }

# ostatne 
host alnet-server { hardware ethernet 00:1E:8C:1B:05:C8; fixed-address 192.168.1.97;}
host qi-xp { hardware ethernet 08:00:27:CA:E3:6F; fixed-address 192.168.1.101;}
host deb-java { hardware ethernet 08:00:27:28:18:64; fixed-address 192.168.1.102; }
host canon4660.printer { hardware ethernet 00:00:85:9F:A2:84; fixed-address 192.168.1.103;}
host akvarko.alnet-server { hardware ethernet 00:24:1D:88:C0:85; fixed-address 192.168.1.108;}
host narezovna-masina { hardware ethernet 00:24:1D:88:C0:85; fixed-address 192.168.1.109;}
host qi-win7 { hardware ethernet 08:00:27:C6:67:B9; fixed-address 192.168.1.111; }

# sietove prvky 
host asus-danad.net { hardware ethernet 00:1E:8C:D0:70:B8; fixed-address 192.168.1.200; ddns-hostname "asus-danad.net"; }
my questions/issues:
1, sometimes, when I just edit MAC address somewhere (physical machine is replaced by a new one and the old one is thrown out) and restart the server daemon with
Code:
/etc/init.d/isc-dhcp-server restart
it says on the new machine that there is an IP address conflict. I have to assign a new IP to a new MAC, I can't re-use them, so I'll run out of IP's in my subnet quickly

2, just today, suddenly, 5 computers on my network stopped to work, their networking was in the state "acquiring IP address". It doesn't matter if this or that PC was with mapped MAC-IP in config file, or without (IP was assigned to it dynamically). They were not able to get IP address at all, they were effectively stuck, all of them at once. Only way to work around that was to set-up static IP address/subnet/gateway to them temporarily.

3, don't know how to set-up logging of dhcp server itself (not just leases). I've seen some guides around but they don't seem to apply to my ubuntu version.

I'm new to dhcp server, this is my first, I don't know how to fix these issues, I've tried to set-up DHCP leases to more aggressive value, no help.

edit: dhcp server is at 192.168.1.9 (ubuntu 11.04 64bit), router is at 192.168.1.1 (including DNS). I've tried to set up my own DNS server but I find it complicated and not necessary for such a small network.
 
Old 04-06-2012, 05:46 PM   #2
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
DHCP magic

The best way to resolve your problems may be to change tools.

DHCPD is a very versital and capable tool, with a few very real complexities. IF you are running pure DHCP you do not need MAC addresses and the dynamic space should have NO FIXED or LONG TERM leases.

Here is an idea: I would ONLY use this for a SMALL lan with no complex requirements.
Instead of DHCPD try using DNSMASQ as your DHCP server. It is small, fast, much easier to configure, and runs well on all versions of Luminx where I have tested it. Being a less complex package, it has documentation that is easier to read and follow.

Manually configure your FIXED IP stations (network services, servers, network devices such as routers, etc) and put them into the /etc/hosts files (DNSMASQ will read and use that information). Configure DNSMASQ to serve dynamic address from a different part of your internal subnet. (For example, 10.7.7.0/24 for your full subnet, fixed devices in 10.7.7.0 - 10.7.7.127, dynamic addresses that DNSMASQ will serve from 10.7.7.128 - 10.7.7.254)

I use this kind of solution on my home network with only 31 nodes and it works great.

DNSMASQ also reads its parent DNS servers from your /etc/resolv.conf file and does automatic DNS caching to speed up lookups and reduce external resolver traffic. This, all without you needing to configure this part. Bonus!
 
1 members found this post helpful.
Old 04-06-2012, 05:50 PM   #3
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
+1 for dnsmasq
 
Old 04-07-2012, 03:30 AM   #4
samopal
LQ Newbie
 
Registered: Aug 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Thumbs up

Quote:
Originally Posted by wpeckham View Post
...
Instead of DHCPD try using DNSMASQ as your DHCP server.
thanks wpeckham for an advice, I've browsed the documentation briefly and it looks like it will fit all my needs, I'm gonna configure it this weekend in my LAN. It's just 20-30 network devices and it won't be growing very fast anytime soon.
 
Old 04-08-2012, 02:38 PM   #5
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
Dnsmasq

You are very welcome, ans I hope it resolves your problem nicely.

Let me know.
 
Old 04-09-2012, 06:44 AM   #6
samopal
LQ Newbie
 
Registered: Aug 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wpeckham View Post
You are very welcome, ans I hope it resolves your problem nicely.

Let me know.
you were right, dnsmasq was quite easy to set-up, I've read a few docs and came up with this configuration, which is results in the same mac-ip mappings as the original isc-dhcp-server:
Code:
# Uncomment this to enable the integrated DHCP server, you need
# to supply the range of addresses available for lease and optionally
# a lease time. If you have more than one network, you will need to
# repeat this for each network on which you want to supply DHCP
# service.
#dhcp-range=192.168.0.50,192.168.0.150,12h
dhcp-range=192.168.1.10,192.168.1.90,12h

# hp-server 00:1C:C4:96:5C:38; fixed-address 192.168.1.9 

# ZD 
dhcp-host=00:1B:EB:20:2D:38,zber1,192.168.1.121
dhcp-host=00:1B:EB:21:18:1F,zber2,192.168.1.122
dhcp-host=00:1B:EB:35:12:6A,zber3,192.168.1.123
dhcp-host=00:1B:EB:21:18:1A,zber4,192.168.1.124

# users cal 
dhcp-host=00:19:DB:D2:7D:93,user1,192.168.1.140
dhcp-host=F4:CE:46:F0:E8:7D,user2,192.168.1.141

# Do the same thing, but using the option name
#dhcp-option=option:router,1.2.3.4
dhcp-option=option:router,192.168.1.1

#subnet mask 
dhcp-option=1,255.255.255.0

#broadcast address 
dhcp-option=28,192.168.1.255

# Set the DHCP server to authoritative mode. In this mode it will barge in
# and take over the lease for any client which broadcasts on the network,
# whether it has a record of the lease or not. This avoids long timeouts
# when a machine wakes up on a new network. DO NOT enable this if there's
# the slightest chance that you might end up accidentally configuring a DHCP
# server for your campus/company accidentally. The ISC server uses
# the same option, and this URL provides more information:
# http://www.isc.org/files/auth.html
#dhcp-authoritative
dhcp-authoritative
my resolv.conf:
Code:
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
only thing that troubles me is, that now I can't ping my PCs by their host name specified in this dnsmasq.conf file,
I've seen some threads about this, I'll try to figure it out when I have time, its a low priority task.
I can only ping network PCs by the hostname they have specified, not those in dnsmasq.conf
 
Old 04-10-2012, 10:00 AM   #7
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
Just Curious

I have not run into the problem, but why would I put a different hostname in the DNSMASQ config than the client machines would request?
 
1 members found this post helpful.
Old 04-11-2012, 06:18 PM   #8
samopal
LQ Newbie
 
Registered: Aug 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wpeckham View Post
I have not run into the problem, but why would I put a different hostname in the DNSMASQ config than the client machines would request?
alright, so imagine this situation:
I have 40 devices on LAN, all of them defined is dnsmasq with MAC->IP mapping and host name.
Imagine I have 10 devices called barebone1, barebone2... barebone10 and they're all mapped and named like this in dnsmasq.conf.
Now barebone3 and barebone4 got broken, I'll quickly replace them with new devices, check the MAC's and update records in dnsmasq.conf and everything should continue working. But I don't want to go inside the configuration of these new devices to set up their host name (they're just plug-and-play linux boxes), they can have different host name defined inside. In network, I want to reach those boxes by the names as they are defined in dnsmasq.conf.

Similar with Windows client PCs, users can accidentally change the "name" of the PC, but I want to be 100% sure that I can reach the PC with that MAC address with it's hostname defined in dnsmasq.conf, I don't want to rely on the local settings of these PCs.

I hope it's clear enough explanation.
 
Old 04-12-2012, 02:24 AM   #9
descendant_command
Senior Member
 
Registered: Mar 2012
Posts: 1,876

Rep: Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643Reputation: 643
From the comments in /etc/dnsmasq.conf
Code:
# Always give the host with ethernet address 11:22:33:44:55:66
# the name fred and IP address 192.168.0.60 and lease time 45 minutes
#dhcp-host=11:22:33:44:55:66,fred,192.168.0.60,45m
 
Old 04-12-2012, 10:02 AM   #10
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
dnsmasq

On the machine running DNSMASQ try loading up the /etc/hosts file with those ip addresses and hostnames.
It will use this in loading its tables on startup for serving names on the local domain.
 
Old 04-13-2012, 04:57 AM   #11
samopal
LQ Newbie
 
Registered: Aug 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wpeckham View Post
On the machine running DNSMASQ try loading up the /etc/hosts file with those ip addresses and hostnames.
It will use this in loading its tables on startup for serving names on the local domain.
yes, this is the first thing that came to my mind, I've tried to add to /etc/hosts:
Code:
192.168.1.111	qi-win7
192.168.1.102	deb
matching machines in dnsmasq.conf:
Code:
dhcp-host=08:00:27:28:18:64,deb,192.168.1.102
dhcp-host=08:00:27:C6:67:B9,qi-win7,192.168.1.111
then I did:
Code:
/etc/init.d/dnsmasq restart
then I've restarted the network interface on the client PC and I still wasn't able to ping it

see:
Code:
C:\Users\admin>ping deb
Ping request could not find host deb. Please check the name and try again.

C:\Users\admin>ping 192.168.1.102

Pinging 192.168.1.102 with 32 bytes of data:
Reply from 192.168.1.102: bytes=32 time<1ms TTL=64
Reply from 192.168.1.102: bytes=32 time<1ms TTL=64
 
Old 04-16-2012, 10:55 AM   #12
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
How very odd....

With the entry in the HOSTS file you should be able to resolve deb to it's IP address even if your /etc/resolv.conf file were messed up and DNSMASQ were not running! It may be that there is something very different blocking your ability to resolve DEB that has nothing to do with BIND, Resolv+, or DNSMASQ.

Try using the 'host' command or nslookup. (Host is the more correct and current.)
Make sure that your /ect/resolv.conf file contains
nameserver (IP of the machine running dnsmasq, even if it is THIS machine)
as the first nameserver line.

Make sure that /etc/hosts contains the line for deb (and only ONE line for deb) as you documented earlier.

type
host deb
and see what returns: it should include 192.168.1.102.

They try
host 192.168.1.102
and see what returns, it should include 'deb' (actually the FQDN for deb).
 
Old 04-17-2012, 09:15 PM   #13
samopal
LQ Newbie
 
Registered: Aug 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wpeckham View Post
With the entry in the HOSTS file you should be able to resolve deb to it's IP address ...
another observation:
With entries only in dnsmasq.conf, I was able reach "deb" machine under it's name correctly from another linux client PC on the same LAN. I've tried to reach other windows machines by their name in dnsmasq.conf (they have a different computer name in their local settings) and I was able to reach them correctly. So I assume the problem is in the windows client PC settings, when I simply type \\%dnsmasq_name%, I can't reach that machine, only by it's IP.

my resolv.conf on dnsmasq server:
Code:
nameserver 127.0.0.1
nameserver 8.8.8.8
nameserver 8.8.4.4
and all (win and linux) clients will pick-up my dnsmasq server's IP as their first dns server.

I didn't touch hosts file, I've tried to add entries there, it did no harm and didn't make windows PC able to reach other machines in the LAN either.
To sum it up:
1, I can reach anything entered in dnsmasq.conf from a linux machine (not only from server machine, from other linux machines on the LAN as well), ex:
Code:
root@itcraft4:~# host deb
deb has address 192.168.1.102
root@itcraft4:~# host qi-win7
qi-win7 has address 192.168.1.111
root@itcraft4:~# host xp-uni2
xp-uni2 has address 192.168.1.105
2, I can't reach anything from a windows machine by it's hostname in dnsmasq. I can only reach other machines by their IP or by their locally set hostname.
 
Old 04-18-2012, 12:47 PM   #14
wpeckham
LQ Guru
 
Registered: Apr 2010
Location: Continental USA
Distribution: Debian, Ubuntu, RedHat, DSL, Puppy, CentOS, Knoppix, Mint-DE, Sparky, VSIDO, tinycore, Q4OS,Manjaro
Posts: 5,591

Rep: Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689Reputation: 2689
OK - so Windows only has a problem

That might seem to indicate to me that the Windows networking is either not configured completely or properly, or is not picking up all of the information it should during DHCP transactions.

Are you very sure that your DNSMASQ server is defined as the first nameserver for your windows machines?
Have you configured the search path to expand local short names to the local FQDN for the hosts?
Have you tried using host or ping against the FQDN (long) hostname of the machines?
 
Old 04-29-2012, 01:55 AM   #15
samopal
LQ Newbie
 
Registered: Aug 2007
Posts: 14

Original Poster
Rep: Reputation: 0
Quote:
Originally Posted by wpeckham View Post
That might seem to indicate to me that the Windows networking is either not configured completely or properly, or is not picking up all of the information it should during DHCP transactions.

Are you very sure that your DNSMASQ server is defined as the first nameserver for your windows machines?
Have you configured the search path to expand local short names to the local FQDN for the hosts?
Have you tried using host or ping against the FQDN (long) hostname of the machines?
all my windows clients have default 'windows' settings and are getting network parameters from dhcp correctly (I guess). Running "ipconfig /all" on any machine results in:
Code:
IP Address. . . . . . . . . . . . : 192.168.1.105
Subnet Mask . . . . . . . . . . . : 255.255.255.0
Default Gateway . . . . . . . . . : 192.168.1.1
DHCP Server . . . . . . . . . . . : 192.168.1.9
DNS Servers . . . . . . . . . . . : 192.168.1.9
which is correct.

Quote:
Have you configured the search path to expand local short names to the local FQDN for the hosts?
Have you tried using host or ping against the FQDN (long) hostname of the machines?
I don't think I fully understand, I don't have a domain set-up in my network, this is probably what you're referring to. I've just filled in the hostnames to dnsmasq.conf on dns/dhcp server and wasn't able to reach machines under those names from windows machines. So I guess answer is no, but I can try to play with it this weekend.
 
  


Reply


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
Damn Small Linux - DHCP Server help! rdsgi Linux - Newbie 1 08-10-2011 12:04 PM
Newbie :dhcp3 as DHCP + dnsmasq as DNS for small LAN ? Umanga Linux - Server 1 02-26-2010 04:14 AM
Postfix without DNS Server for Small LAN LinuxGeek Linux - Networking 5 12-19-2006 08:00 AM
imap mail server for small LAN uberNUT69 Linux - Software 8 04-26-2005 09:32 AM
How do you make the ip masquerade server/dhcp server broadcast dns to lan cmisip Linux - Networking 6 01-25-2003 10:43 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 09:00 PM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration