3

I have bought a RPI 2 for my 3D printer. My purpose is to access it remotely via wifi. I don't have a router, so I have created an Access Point on the RPI. I have also installed dnsmasq as the DHCP server.

Everything is working... except the DHCP service ! I can connect without any problem to my RPI only if I manually give an IP address to my computer

I have tried lots of different parameters for dnsmasq without success. I have listed my "final" configuration files. Do you have an idea what is wrong ?

/etc/network/interfaces

auto wlan0
allow-hotplug wlan0
iface wlan inet static
address 192.168.1.1
netmask 255.255.255.0

_

/etc/hostapd/hostapd.conf

interface=wlan0
driver=rtl871xdrv
ssid=RPI_Octoprint
hw_mode=g
channel=6
macaddr_acl=0
auth_algs=1
ignore_broadcast_ssid=0
wpa=1
wpa_passphrase=password
wpa_key_mgmt=WPA-PSK
wpa_pairwise=TKIP
rsn_pairwise=CCMP

And at the end of the following file, I have added: (not sure that dhcp option 3 and 6 are useful...)

/etc/dnsmasq.conf

expand-hosts
interface=wlan0
dhcp-autoritative
dhcp-range=192.168.1.2,192.168.1.20,12h
dhcp-range=1,255.255.255.0
dhcp-range=3,192.168.1.1
dhcp-range=6,192.168.1.1

And I have also added (not sure what it is doing):

/etc/hosts
192.168.1.1 main

Thank you ! :)

  • 1
    Hello have you managed to solve your problem? – Nemikolh Jul 19 '17 at 10:48
1

I understand that this is most likely a dead post, but I stumbled upon it while looking for an answer to my issue and noticed the following straight off...

The issue appears to be that the OP missed this in the /etc/dnsmasq.conf:

dhcp-autoritative

which should have read:

dhcp-authoritative
  • Imho that's a simple typo, because OP has other typos such as the interface name wlan instead of wlan0 in the /etc/network/interface config. – David Artmann Jun 25 at 19:10
0

All you should need is a single dhcp-range=192.168.1.2,192.168.1.20,12h line for the range. dnsmasq has a lot of additional options ranges for conditional ranges, but for a simple scenario like you've described, the single line should suffice.

If you're just appending lines to /etc/dnsmasq.conf, make sure there aren't spurious entries above. The default raspbian file has a lot of helpful information, but there's so much in there it's easy to double-up on entries. You might want to create a clean version with only your lines in it.

dhcp-options are specified with dhcp-option lines. I use them to specify default gateway, WINS server, default domain and the like.

Try changing these 3 lines:

dhcp-range=1,255.255.255.0
dhcp-range=3,192.168.1.1
dhcp-range=6,192.168.1.1

into dhcp-options.

# subnet mask
dhcp-option=1,255.255.255.0
# gateway
dhcp-option=3,192.168.1.1
# dns
dhcp-option=6,192.168.1.1
  • Thank you for the explanation and to have pointed out my mistake ! I have tried with the corrected dhcp-option line and without and it is still not working. I have also cleaned the dnsmasq.conf file. On my computer, when I try to connect to the RPI, I'm seeing: DHCP activated / Computer's IP: 169.254.224.62 / Mask: 255.255.255.0 and some IPV6 stuffs. I have also observed that in my /etc/ folder, I have a dhcpcd.conf file which is empty and I think this file is related to the dhcp3 package. May be there is a conflict ? Thank you. – Lmecano Jul 29 '15 at 16:25
  • Could it be as simple as dnsmasq not being enabled? Check the /etc/default/dnsmasq file and make sure it reads ENABLED=1. – bobstro Jul 29 '15 at 23:09
  • The line is uncommented. I have tried to do sudo /etc/init.d/dnsmasq restart and I got [FAIL] Restarting DNS forwarder and DHCP server: configuration syntax check failed!. I had a look on internet and it is said to check /etc/dnsmasq.conf and /etc/dhcp3/dhclient.conf. Unfortunately, the dhcp3 folder is empty. Do I need to install dhcp3 package ? It seems weird. Thank you. – Lmecano Jul 30 '15 at 19:35
  • No, you shouldn't need to install dhcp3. The error indicates a typo somewhere, so at least the problem makes sense. Can you sanitize the file and dump it in a pastebin perhaps? Did you fix those dhcp-range lines? – bobstro Jul 30 '15 at 22:36
  • Yeah, I fixed it. Here is my files. pastebin.com/91dMs2zh -> Configuration file of dnsmasq. // pastebin.com/AJth32wa -> Network configuration // pastebin.com/FNF0k81q -> This file is of particular interest as it is telling me that the configuration file has to be in this folder.... I have tried without success. I have also this file: pastebin.com/n83k6Z0P but I don't get it as I didn't install dhcpcd. May be my computer with W8.1 can't connect to a RPI... I will try with another computer as soon as possible. – Lmecano Jul 31 '15 at 17:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.