iFunction
Posts: 74
Joined: Wed Nov 18, 2015 4:16 pm

trying to set up DNS DHCP server

Thu Jan 21, 2016 5:35 pm

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

fruitoftheloom
Posts: 23337
Joined: Tue Mar 25, 2014 12:40 pm
Location: Delightful Dorset

Re: trying to set up DNS DHCP server

Thu Jan 21, 2016 5:38 pm

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
Rather than negativity think outside the box !
RPi 4B 4GB (SSD Boot)..
Asus ChromeBox 3 Celeron is my other computer...

iFunction
Posts: 74
Joined: Wed Nov 18, 2015 4:16 pm

Re: trying to set up DNS DHCP server

Fri Jan 22, 2016 4:10 pm

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?

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: trying to set up DNS DHCP server

Sat Jan 23, 2016 12:01 am

Add the name you would like to use and the IP address to the `/etc/hosts` file.
Account Inactive

iFunction
Posts: 74
Joined: Wed Nov 18, 2015 4:16 pm

Re: trying to set up DNS DHCP server

Mon Jan 25, 2016 5:42 am

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?

SonOfAMotherlessGoat
Posts: 690
Joined: Tue Jun 16, 2015 6:01 am

Re: trying to set up DNS DHCP server

Mon Jan 25, 2016 6:02 am

So are you saying the DHCP server itself will be assigned an address by DHCP?
Account Inactive

FM81
Posts: 518
Joined: Wed Apr 17, 2013 4:33 pm

Re: trying to set up DNS DHCP server

Mon Jan 25, 2016 6:21 am

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
A: What does the command 'cat /dev/urandom', can you tell me please?
B: Yeah, that's very simple: It feeds your cat with radioactive material!

ripat
Posts: 191
Joined: Tue Jul 31, 2012 11:51 am
Location: Belgium

Re: trying to set up DNS DHCP server

Mon Jan 25, 2016 8:05 am

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.
Using Linux command line usually boils down to these three things:
#1) Respect the privacy of others.
#2) Think before you type.
#3) With great power comes great responsibility.

iFunction
Posts: 74
Joined: Wed Nov 18, 2015 4:16 pm

Re: trying to set up DNS DHCP server

Mon Jan 25, 2016 3:08 pm

@ 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

iFunction
Posts: 74
Joined: Wed Nov 18, 2015 4:16 pm

Re: trying to set up DNS DHCP server

Mon Jan 25, 2016 3:59 pm

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

Return to “Beginners”