Page 1 of 1

trying to set up DNS DHCP server

Posted: Thu Jan 21, 2016 5:35 pm
by iFunction
Hi there,

I am trying to learn how to do this using dnsmasq, but I am getting stuck really early on. I don't have a domain, I just have our home router, yet everyone is saying that this line is really important, yet no one actually says what it should be if you don't own your own domain name.

I have been trying to follow this tutorial:
http://www.andrewoberstar.com/blog/2012 ... s-and-dhcp

What am I supposed to put for this line:

Code: Select all

# won't forward requests for your intranet subdomain
local=/lan.mydomain.com/
any help on this would be much appreciated.

iFunc

Re: trying to set up DNS DHCP server

Posted: Thu Jan 21, 2016 5:38 pm
by fruitoftheloom
iFunction wrote:Hi there,

I am trying to learn how to do this using dnsmasq, but I am getting stuck really early on. I don't have a domain, I just have our home router, yet everyone is saying that this line is really important, yet no one actually says what it should be if you don't own your own domain name.

I have been trying to follow this tutorial:
http://www.andrewoberstar.com/blog/2012 ... s-and-dhcp

What am I supposed to put for this line:

Code: Select all

# won't forward requests for your intranet subdomain
local=/lan.mydomain.com/
any help on this would be much appreciated.

iFunc
:?: :?: https://wiki.debian.org/HowTo/dnsmasq

Re: trying to set up DNS DHCP server

Posted: Fri Jan 22, 2016 4:10 pm
by iFunction
Thanks for this, it has cleared up a few things. What I am trying to do is basically ssh another raspberry pi using a name and not an ip address, but I can't work out how to do that from this tutorial.

Am I on completely the wrong track?

Re: trying to set up DNS DHCP server

Posted: Sat Jan 23, 2016 12:01 am
by SonOfAMotherlessGoat
Add the name you would like to use and the IP address to the `/etc/hosts` file.

Re: trying to set up DNS DHCP server

Posted: Mon Jan 25, 2016 5:42 am
by iFunction
But that won't work when the ip address gets reassigned by DHCP will it. I would rather use static ip addresses for this project, but it turns out that I can't.

Are you saying that this is not possible of a raspberry pi, if so why can you turn it into a DHCP server?

Re: trying to set up DNS DHCP server

Posted: Mon Jan 25, 2016 6:02 am
by SonOfAMotherlessGoat
So are you saying the DHCP server itself will be assigned an address by DHCP?

Re: trying to set up DNS DHCP server

Posted: Mon Jan 25, 2016 6:21 am
by FM81
DNSMASQ works fine on a Raspberry-Pi.
A line in the config-file for defining any hostname could look like

Code: Select all

dhcp-host=ab:cd:ef:12:34:56,host-xyz,192.168.0.222
In this case the the given name to the mac-address ab:cd:ef:12:34:56 would be host-xyz and it would have always the ip-address 192.168.0.222 for example.

The name of the dnsmasq-server itself you should define in it's own /etc/hosts or in any additional HOSTS-file, which you can define also in the config. (Last part is optional.)

Greetings, FM_81

Re: trying to set up DNS DHCP server

Posted: Mon Jan 25, 2016 8:05 am
by ripat
I understand that you want to setup a DHCP and DNS server on a pi to serve local hostnames.

First you want to make sure that it will be the only one DHCP server on your lan. This is important if you want local name resolution to work properly and avoid double ip assignment. Then, as your pi is not your network gateway, it will also have to give your main gateway (router) address in the answer to an ip request.

This is a very basic dnsmasq.conf that should work:

Code: Select all

# interface to listen on
interface=eth0

# upstream DNS servers (google ones or your ISP's)
server=8.8.8.8
server=8.8.4.4

# range of addresses to lease
dhcp-range=192.168.0.5,192.168.0.100,255.255.255.0,1h

# gateway (router) address
dhcp-option=option:router,192.168.0.1
Now, be careful because if the pi running dnsmasq crashes, the hosts on you LAN would have no DHCP server to get an ip lease from. No ip, no route, no internet, no lan. In that case, make sure you can either restart the DHCP on your main router with a factory reset or otherwise, or have a direct access (keyboard + monitor or serial) to your pi for troubleshooting.

Last side note, don't forget to restart dnsmasq after every change in its conf file and make sure every host on your lan have a different hostname otherwise the local name resolution will not work as expected.

Re: trying to set up DNS DHCP server

Posted: Mon Jan 25, 2016 3:08 pm
by iFunction
@ ripat, Thank you very much, this gives me a starting point, I will try this when I get home as I know my home network. I originally just wanted to use static ip addresses, as this would have worked well, however, as we are not providing the router for this touring network currently, setting up a dns/dhcp server is the sensible way to go, though it is a lot harder to navigate than I thought it might be.

@SonOfAMotherlessGoat, no I don't mean that at all, what I mean is that I have no clue what I am doing currently and I am trying to learn from scratch.

Thanks for your input, I'll no doubt be posting back with more questions on this one.

Kind regards
iFunc

Re: trying to set up DNS DHCP server

Posted: Mon Jan 25, 2016 3:59 pm
by iFunction
Thank you, it works, well it works so far with the one pi, I will be able to test it with 4 of them later this evening? :D

Kindest regards
iFunk