aksin
Posts: 55
Joined: Fri May 22, 2015 8:10 am

fail to start dnsmasq in Jessie

Wed Dec 09, 2015 4:31 am

i have set an AP on my wifi (with static ip 192.168.22.1),and i want all url direct to this static ip
Here is my setting under /etc/dnsmasq.conf:

Code: Select all

address=/#/192.168.22.1
interface=wlan0
no-resolv
server=8.8.8.8
server=8.8.4.4
dhcp-range=192.168.22.2,192.168.22.22,255.255.255.0,1h
when i start the dnsmasq with

Code: Select all

sudo /etc/init.d/dnsmasq start
it return this

Code: Select all

[....] Starting dnsmasq (via systemctl): dnsmasq.serviceJob for dnsmasq.service failed. See 'systemctl status dnsmasq.service' and 'journalctl -xn' for details.
 failed!
i check with

Code: Select all

systemctl status dnsmasq.service
, it return this

Code: Select all

● dnsmasq.service - dnsmasq - A lightweight DHCP and caching DNS server
   Loaded: loaded (/lib/systemd/system/dnsmasq.service; enabled)
  Drop-In: /run/systemd/generator/dnsmasq.service.d
           └─50-dnsmasq-$named.conf, 50-insserv.conf-$named.conf
   Active: failed (Result: exit-code) since Wed 2015-12-09 04:28:30 UTC; 1min 24s ago
  Process: 5456 ExecStart=/etc/init.d/dnsmasq systemd-exec (code=exited, status=3)
  Process: 5454 ExecStartPre=/usr/sbin/dnsmasq --test (code=exited, status=0/SUCCESS)
any idea?

aksin
Posts: 55
Joined: Fri May 22, 2015 8:10 am

Re: fail to start dnsmasq in Jessie

Thu Dec 10, 2015 3:34 pm

Any solution for this?

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

Re: fail to start dnsmasq in Jessie

Thu Dec 10, 2015 3:55 pm

Check the syntax of your conf file with:

Code: Select all

sudo dnsmasq --test
Beside this, I am not sure the redirection will 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.

aksin
Posts: 55
Joined: Fri May 22, 2015 8:10 am

Re: fail to start dnsmasq in Jessie

Thu Dec 10, 2015 3:57 pm

ripat wrote:Check the syntax of your conf file with:

Code: Select all

sudo dnsmasq --test
Beside this, I am not sure the redirection will work as expected.
It said syntax is OK.

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

Re: fail to start dnsmasq in Jessie

Thu Dec 10, 2015 4:12 pm

I have just tried your conf file and it starts flawlessly on my Pi with Jessie.

systemctl, when used to start dnsmasq is not very verbose. Just try to start the service just like this:

Code: Select all

sudo dnsmasq
If it start all right, to stop it:

Code: Select all

sudo kill -9 $(pidof dnsmasq)
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.

aksin
Posts: 55
Joined: Fri May 22, 2015 8:10 am

Re: fail to start dnsmasq in Jessie

Fri Dec 11, 2015 3:19 am

ripat wrote:I have just tried your conf file and it starts flawlessly on my Pi with Jessie.

systemctl, when used to start dnsmasq is not very verbose. Just try to start the service just like this:

Code: Select all

sudo dnsmasq
If it start all right, to stop it:

Code: Select all

sudo kill -9 $(pidof dnsmasq)
Thanks , it works....
as you expected, it will not redirect all url to my fixed ip.
when i test it will my ios phone, it only works on http or hello.com. but this not working when i test it on OSX laptop.
Any suggestion? or tutorial i can refer to?
( if redirecting all url cant be done, at least make it work with certain fixed easy typing url like 'hi.local' )

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

Re: fail to start dnsmasq in Jessie

Fri Dec 11, 2015 6:55 am

What are you trying to achieve? Dnsmasq will resolve all domain names to the fixed ip you have setup in the conf file. And it will only do that, no more, no less. On that address, you will need a server that will respond to all requests using a domain name: a http server, ftp server, mail server etc...
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.

aksin
Posts: 55
Joined: Fri May 22, 2015 8:10 am

Re: fail to start dnsmasq in Jessie

Sat Dec 12, 2015 2:51 am

ripat wrote:What are you trying to achieve? Dnsmasq will resolve all domain names to the fixed ip you have setup in the conf file. And it will only do that, no more, no less. On that address, you will need a server that will respond to all requests using a domain name: a http server, ftp server, mail server etc...
here is what i try to achieve:
i have a lighttpd to host a webpage, when people connect my AP, any URL they type will redirect to that webpage ( kind of captive portal). OR, people type url: hi.local, it will redirect to that webpage.

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

Re: fail to start dnsmasq in Jessie

Sat Dec 12, 2015 7:42 am

Ok, so you have a server on the other end.

In your post 54 above you say that the redirection works for some device but not for others. Did you try to flush the local DNS cache of these devices? When you ping, say google.com, on these devices, what ip address replies? Your AP?
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.

s7lx
Posts: 1
Joined: Fri Mar 04, 2016 12:32 pm

Re: fail to start dnsmasq in Jessie

Fri Mar 04, 2016 12:38 pm

Follow me

Code: Select all

sudo vim /etc/init.d/dnsmasq
then find

Code: Select all

if [ -f $ROOT_DS ]; then
   DNSMASQ_OPTS="$DNSMASQ_OPTS `sed -e s/". IN DS "/--trust-anchor=.,/ -e s/" "/,/g $ROOT_DS | tr '\n' ' '`"
fi
That makes error.

SO

delete it.

ok, done.

try

Code: Select all

sudo service dnsmasq restart 

Jeffe35
Posts: 1
Joined: Tue Jun 12, 2018 8:43 pm

Re: fail to start dnsmasq in Jessie

Tue Jun 12, 2018 8:52 pm

I'm having problem with starting dnsmasq. Here is the code I have...

interface=wlan0
dhcp-
range=192.168.4.2, 192.168.4.20, 255.255.255.0, 24

That's it.

Run dnsmasq --test

And it says bad option at line 2

What's wrong? Please help me thanks in advance.

Return to “Beginners”