You are not logged in.

#1 2004-08-26 18:35:24

ActionNews
Member
From: Augsburg (Germany)
Registered: 2004-02-24
Posts: 150
Website

dnsmasq - how to configure

Hello!

I have some problems with DNS which is sometimes very slow (takes sometimes 10-15 seconds), so somebody gave me the hint to use a own DNS-Server with dnsmasq. Nicely i found dnsmasq listed in the Arch-Prepos. But what do i have to do to make it work with ArchLinux ?

CU ActionNews


[URL=http://www.nethands.de/athlon/show.php3?user=actionnews]My System[/URL] - one click ahead!

Offline

#2 2004-08-26 18:44:46

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: dnsmasq - how to configure

Install it (pacman -S dnsmasq) and then start it as a service (in /etc/rc.conf put dnsmasq in the DAEMONS=... line "DAEMONS=(syslog-ng network dnsmasq ..." and then point /etc/resolv.conf to your localhost (nameserver 127.0.0.1) and that should do it.  You dont need to reboot, just make the file changes and then:

/etc/rc.d/dnsmasq start
/etc/rc.d/network restart

Edit, whoops, the resolv.conf won't work.  You need the old dns sever for the forwarding.  It will only works like that for computers behind the dnsmasq network.  If you only have one computer, maybe you really want bind or djbdns.

Check out all you need to know...
http://ftp.axis.se/pub/users/cii/floppy … q/doc.html

Offline

#3 2004-08-26 19:10:12

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: dnsmasq - how to configure

Erm, just use the -r option.

I start dnsmasq as:

dnsmasq -f -r /etc/ppp/resolv.conf -I ppp0 
-A /googlesyndication.com/127.0.0.1 
-A /doubleclick.net/127.0.0.1 
-A /valueclick.com/127.0.0.1

My resolv.conf has 127.0.0.1 as dns server.

Dnsmasq is only good for caching, which speeds up overall DNS resolving, mainly with Firefox. What your real problem is that you use bad DNS servers, you should try to find good ones near you (your ISP should have some).

Offline

#4 2004-08-26 19:35:29

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: dnsmasq - how to configure

Thanks i3839. 

So I tried this and it worked for me...

pacman -S dnsmasq
mkdir /etc/dnsmasq
mv /etc/resolv.conf /etc/dnsmasq
cd /etc
echo nameserver 127.0.0.1 > resolv.conf
mv rc.conf rc.conf.save 
sed  '/DAEMON/s/network/network dnsmasq.local/g' rc.conf.save>rc.conf
cd rc.d
sed  '/-z/s/dnsmasq/dnsmasq -r /etc/dnsmasq/resolv.conf /g' dnsmasq>dnsmasq.local
/etc/rc.d/dnsmasq.local start
/etc/rc.d/network restart

Offline

#5 2004-08-26 20:19:23

ActionNews
Member
From: Augsburg (Germany)
Registered: 2004-02-24
Posts: 150
Website

Re: dnsmasq - how to configure

Thank you it works smile. Much better now smile.
Backuped my old /etc/resolv.conf (/etc/resolv.conf.dnsmasq) and changed the nameserver in /etc/resolv.conf to 127.0.0.1, then startet the dnsmasq deamon and restartet network.  Thats all.

CU ActionNews


[URL=http://www.nethands.de/athlon/show.php3?user=actionnews]My System[/URL] - one click ahead!

Offline

#6 2004-08-26 20:28:41

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: dnsmasq - how to configure

I just added that previously mentioned line to rc.local, much easier than editing all those other files...

Offline

#7 2004-08-27 12:13:34

Iolo
Member
Registered: 2004-06-03
Posts: 38

Re: dnsmasq - how to configure

What exactly does :

sed  '/DAEMON/s/network/network dnsmasq.local/g' rc.conf.save>rc.conf

and

sed  '/-z/s/dnsmasq/dnsmasq -r /etc/dnsmasq/resolv.conf /g' dnsmasq>dnsmasq.local

do?

Offline

#8 2004-08-27 13:32:59

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: dnsmasq - how to configure

That's "editing all those other files", in an unnecessary complicated way if I may add. No idea why he doesn't use the -i option though.

Offline

#9 2004-08-27 13:47:38

Iolo
Member
Registered: 2004-06-03
Posts: 38

Re: dnsmasq - how to configure

Okay, that makes sense,

The instructions seem to works if you are using an static ip, but what if you  are using dhcp on a router? Restarting the network daemon after dnsmasq will wipe out  the "nameserver 127.0.0.1 line" in the resolv.conf. Is there a way to prevent this?

Offline

#10 2004-08-27 15:57:51

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: dnsmasq - how to configure

I3839, I didnt think I needed to ignore ppp0.  I just put it all down because that is what I did and it worked.  Used sed because I would have to say " edit x and replace line y with y' " otherwise.   I tried your command interactively and it didn't work for me, but I see now that it was because my /etc/ppp/resolv.conf was empty.  Yours is superior if you are on dsl, but you still have to edit files if you are on cable and the ppp resolv.conf is not set up.

Anyway, Iolo, to make things more complicated, you can edit /etc/rc.d/network and edit the line in the ifup() section to read:

    /usr/sbin/dhcpcd -R -t 10 -h $HOSTNAME $1

The "-R" keeps dhcpcd from replacing /etc/resolv.conf.

Offline

#11 2004-08-27 17:23:36

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: dnsmasq - how to configure

If the DNS servers reported by dhcp are good (which doesn't seem to be the case for you because you complained about slow resolving), then it would be nice if you could tell dhcp to write another file than resolv.conf, which can be used by dnsmasq.

I ignore ppp0 because that's my adsl connection (using pppoa). It's not needed because incomming connections aren't allowed by my firewall, and even if people would use my dnsmasq then that's no disaster. It's just the config I use and that's all I said.

Offline

#12 2004-08-27 17:33:11

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: dnsmasq - how to configure

Yeah, that would be better, the -R in my post only works as long as the present servers (found by dhcp the last time you ran w/o -R) are valid.  If the isp changes them, then the /etc/resolv.conf will be looking at dead servers.

Offline

#13 2004-08-27 17:50:54

Iolo
Member
Registered: 2004-06-03
Posts: 38

Re: dnsmasq - how to configure

Well, does the system query resolv.conf at the time it is written, or as needed (when apps call for a DNS)? if the later, why not try editing /etc/rc.d/network and edit the line in the ifup() section to read:

/usr/sbin/dhcpcd -t 10 -h $HOSTNAME $1
mv /etc/resolv.conf /etc/dnsmasq/resolv.conf
echo nameserver 127.0.0.1 > /etc/resolv.conf


Then edit /etc/rc.d/dnsmasq  script under start to read:

[ -z "$PID" ] && /usr/sbin/dnsmasq -r /etc/dnsmasq/resolv.conf

Offline

#14 2004-08-29 08:14:03

dammit
Member
Registered: 2004-07-06
Posts: 67

Re: dnsmasq - how to configure

Hi,
i was just wondering only available with dhcp.
Cuz atm dnsmasq seems to improve my internet access responsiveness, but it has changed my computer ip address to dhcp address. 

I did what colnago suggested and it worked, but i want to get my old static ip address for my pc, since it's connected to a router and i require port forwarding for apps like bittorrent.

I dont really get what dnsmasq, all i know that it help with caching sites that i go often and internet seems faster.

thanks
dammit

Offline

#15 2004-08-29 15:39:30

i3839
Member
Registered: 2004-02-04
Posts: 1,185

Re: dnsmasq - how to configure

Dnsmasq is a caching DNS server, and it's also a DHCP server (not enabled by default as far as I know). It doesn't cache sites, but only DNS addresses, so resolving urls is much faster if it's in the cache.

If you want a static IP then you shouldn't use dhcp.

Offline

#16 2004-08-29 16:08:02

dammit
Member
Registered: 2004-07-06
Posts: 67

Re: dnsmasq - how to configure

Hi how do i enable static ip.
cuz i would like the dns cache thing but not the dhcp.
how to disable dhcp

Offline

#17 2004-08-29 18:23:09

colnago
Member
From: Victoria, BC
Registered: 2004-03-25
Posts: 438

Re: dnsmasq - how to configure

This is off topic a bit, you don't do any changes to the dnsmasq setup.

It is done in /etc/rc.conf.  For example, a static IP of 192.168.0.100 in a 192.168.0.x subnet:

lo="lo 127.0.0.1"
eth0="eth0 192.168.0.100 netmask 255.255.255.0 broadcast 192.168.0.255"
INTERFACES=(lo eth0)
gateway="default gw 192.168.0.1"
ROUTES=(gateway)

...and, assuming your computer name is 'anarchcomputer', hosts:

127.0.0.1               localhost.localdomain   localhost anarchcomputer

or

127.0.0.1               localhost.localdomain   localhost 
192.168.0.100          anarchcomputer

Offline

#18 2005-11-25 18:53:43

anglian252
Member
Registered: 2005-05-01
Posts: 25

Re: dnsmasq - how to configure

Whenever I do /etc/rc.d/dnsmasq.local start  I get Permission Denied....any ideas anyone?

Offline

#19 2005-11-25 19:12:03

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: dnsmasq - how to configure

You need to run

/etc/rc.d/dnsmasq.local start

as root.

Offline

#20 2005-11-25 20:05:14

anglian252
Member
Registered: 2005-05-01
Posts: 25

Re: dnsmasq - how to configure

I am:-

[root@myhost swatson]# /etc/rc.d/dnsmasq.local start
bash: /etc/rc.d/dnsmasq.local: Permission denied
[root@myhost swatson]#

Offline

#21 2005-11-25 20:11:15

Snowman
Developer/Forum Fellow
From: Montreal, Canada
Registered: 2004-08-20
Posts: 5,212

Re: dnsmasq - how to configure

Does /etc/rc.d/dnsmasq.local has executable permission?

Offline

#22 2005-11-25 20:17:38

anglian252
Member
Registered: 2005-05-01
Posts: 25

Re: dnsmasq - how to configure

No, but it does now! all working.....

Offline

#23 2005-11-26 21:04:10

johnisevil
Member
From: Hamilton, ON Canada
Registered: 2003-08-07
Posts: 221
Website

Re: dnsmasq - how to configure

Going through this thread and trying the suggestions, I get an error when starting /etc/rc.d/dnsmasq and blocking things like Google syndication ads doesn't work.  This is the appropriate line from /etc/dnsmasq.conf:

address=/doubleclick.net/127.0.0.1,/googlesyndication.com/127.0.0.1,/valueclick.com/127.0.0.1

Offline

#24 2005-11-26 22:43:45

johnisevil
Member
From: Hamilton, ON Canada
Registered: 2003-08-07
Posts: 221
Website

Re: dnsmasq - how to configure

Nevermind, found my problem.  Anyone using this to block ads by forwarding them to another address, the syntax is 1 per line like so:

address=/doubleclick.net/127.0.0.1
address=/googlesyndication.com/127.0.0.1
address=/valueclick.com/127.0.0.1

Offline

Board footer

Powered by FluxBB