[SOLVED] [SOLVED] How to create a caching dns server in centos
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
127.0.0.1 is OK, as long as you also use the interface option.
It is also OK to use 127.0.0.1 in the resolv.conf file, works fine here.
Of course, if you want to connect with other machines on that port the port must be open.
If listen-address is used in dnsmasq.conf, then it restricts dnsmasq to listen only on that address/interface.
With
listen-address = 127.0.0.1
Other machines on the LAN cannot connect. This is what LeoPap has in his config.
To allow other LAN boxes to connect to dnsmasq, the options are (1) change the listen-address to the LAN IP, or (2) remove the listen-address line entirely -- in which case dnsmasq listens on ALL interfaces.
Either approach is viable. I opted for the former. In retrospect it may have been simpler to have said, "put a # at the beginning on the 'listen-address' line and restart dnsmasq."
If listen-address is used in dnsmasq.conf, then it restricts dnsmasq to listen only on that address/interface.
With
listen-address = 127.0.0.1
Other machines on the LAN cannot connect. This is what LeoPap has in his config.
To allow other LAN boxes to connect to dnsmasq, the options are (1) change the listen-address to the LAN IP, or (2) remove the listen-address line entirely -- in which case dnsmasq listens on ALL interfaces.
Either approach is viable. I opted for the former. In retrospect it may have been simpler to have said, "put a # at the beginning on the 'listen-address' line and restart dnsmasq."
Sorry, but wrong. Have a look at my config file posted earlier in the thread, it is working fine for me, connecting from different machines (Linux and Windows) to that server.
This is what the man-page of dnsmasq has to say about that:
Quote:
Both --interface and --listen-address options may be given, in which case the set of both interfaces and addresses is used. Note that if no --interface option is given, but --listen-address is, dnsmasq will not automatically listen on the loopback interface. To achieve this, its IP address, 127.0.0.1, must be explicitly given as a --listen-address option.
So, if you have the interface specified in the config file giving the value of 127.0.0.1 to the listen-address option is not only totally OK, but in this case enables wanted behavior.
After using the caching server for 2 days on my windows pc's, i have noticed that the speed of browsing didn't have a dramatically change...Maybe it is a bit better than it was previously but not what i was expected...
Is there anything else i can do in order to get faster browsing?
Also is there any way to see if the cache-size has been reduced??
Browsing of course only becomes faster for things that are cached, for example if you visit a site that you have visited before. And of course, as unSpawn stated already, you restarting the machine or dnsmasq will clear the cache, so that is a no-go. I use it to speed up my different machines (a machine has not look up DNS info that I have already visited on a different machine), especially when network load is high, and you really can see the difference. I can't say anything about performance on single machines that are used on home networks without other machines interfering.
If you often visit the same sites with somewhat static content it may help to use a caching proxy server, like Polipo (again, not really data here for that with single machines on single used home networks), that gave me a serious speed up, again especially when network load is high.
I check the log file of dnsmasq and here are the results.
[root@localhost ~]# cat /var/log/dnsmasq.log
Jan 3 09:10:09 dnsmasq[1601]: started, version 2.48 cachesize 1000
Jan 3 09:10:09 dnsmasq[1601]: compile time options: IPv6 GNU-getopt DBus no-I18 N DHCP TFTP
Jan 3 09:10:09 dnsmasq[1601]: cleared cache
Jan 3 09:10:09 dnsmasq[1601]: failed to read /etc/resolv.dnsmasq: No such file or directory
Jan 3 09:21:47 dnsmasq[1601]: exiting on receipt of SIGTERM
Jan 3 09:21:53 dnsmasq[1627]: started, version 2.48 cachesize 1000
Jan 3 09:21:53 dnsmasq[1627]: compile time options: IPv6 GNU-getopt DBus no-I18 N DHCP TFTP
Jan 3 09:21:53 dnsmasq[1627]: cleared cache
Jan 3 09:21:53 dnsmasq[1627]: failed to read /etc/resolv.dnsmasq: No such file or directory
Jan 3 09:22:09 dnsmasq[1627]: exiting on receipt of SIGTERM
Jan 3 09:22:09 dnsmasq[1653]: started, version 2.48 cachesize 1000
Jan 3 09:22:09 dnsmasq[1653]: compile time options: IPv6 GNU-getopt DBus no-I18 N DHCP TFTP
Jan 3 09:22:09 dnsmasq[1653]: cleared cache
Jan 3 09:22:09 dnsmasq[1653]: failed to read /etc/resolv.dnsmasq: No such file or directory
Jan 4 12:34:21 dnsmasq[1653]: exiting on receipt of SIGTERM
Jan 4 12:35:06 dnsmasq[1041]: started, version 2.48 cachesize 1000
Jan 4 12:35:06 dnsmasq[1041]: compile time options: IPv6 GNU-getopt DBus no-I18 N DHCP TFTP
Jan 4 12:35:06 dnsmasq[1041]: cleared cache
Jan 4 12:35:06 dnsmasq[1041]: failed to read /etc/resolv.dnsmasq: No such file or directory
Jan 7 08:33:25 dnsmasq[1041]: exiting on receipt of SIGTERM
Possibly a permission issue? I can't really say. But what I can see is that your dnsmasq is restarted at least once a day, which will clear the cache and render it more or less useless. It may be that this behavior is caused by the inability to read resolv.dnsmasq, but the real question is: When dnsmasq can't resolve DNS queries on your server because it can't access the file with the nameserver addresses, how can it possibly ever have worked?
Possibly a permission issue? I can't really say. But what I can see is that your dnsmasq is restarted at least once a day, which will clear the cache and render it more or less useless. It may be that this behavior is caused by the inability to read resolv.dnsmasq, but the real question is: When dnsmasq can't resolve DNS queries on your server because it can't access the file with the nameserver addresses, how can it possibly ever have worked?
I really don't know.. I am too confused now! i have change the dns server at my windows pc ( i add the ip of the caching server ) and i had internet connection!! How can this be possible?
When i install dnsmasq, i also type these commands:
groupadd -r dnsmasq
useradd -r -g dnsmasq dnsmasq
How can i be sure that it is not a permission issue?
Also if you see the log file stops at 7 of January..Why i don't have any data from 8 and 9 of January??
(and I seem to have failed in copy and paste, this line is the last in my config file), this is why you don't have anything in your log file, dnsmasq is just not logging.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.