LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Networking
User Name
Password
Linux - Networking This forum is for any issue related to networks or networking.
Routing, network cards, OSI, etc. Anything is fair game.

Notices


Reply
  Search this Thread
Old 12-15-2009, 02:01 PM   #1
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
dnsmasq: how to prevent upstream queries for hosts in /etc/hosts?


Hello

This question arises from my LQ thread "OOo: when no Internet: very slow to start and does not open file" in which Skaperen kindly helped me resolve the underlying problem as dnsmasq querying the upstream DNS servers to resolve the local machine, CW8, which is listed in /etc/hosts when OOo tries to resolve that name.

Research showed that this is default dnsmasq behaviour and that solution (as I understand it) is to:
  1. Add an entry in /etc/hosts for the local computer including a local domain name. This was done (the registered domain name is required for sendmail to send mail as originating from that domain)
    Code:
    192.168.1.47    CW8 CW8.<registered domain name not shown> CW8.localdomain
  2. Configure dnsmasq:
    • To add a domain name to hostnames without domain names
    • With a domain name to add as above
    • To use only /etc/hosts for the local domain

    I changed /etc/dnsmasq.conf accordingly, adding:
    Code:
    # Set this (and domain: see below) if you want to have a domain
    # automatically added to simple names in a hosts-file.
    expand-hosts
    
    # Set the domain for dnsmasq. this is optional, but if it is set, it
    # does the following things.
    [snip]
    # 3) Provides the domain part for "expand-hosts"
    domain=localhost
    
    # Add local-only domains here, queries in these domains are answered
    # from /etc/hosts or DHCP only.
    local=/localdomain/
After making these changes and restarting dnsmasq I tested by opening an OOo document and saw that the changes had not stopped
Code:
root:/etc# tcpdump -nnl -i eth0 -s 1536 dst port 53
tcpdump: verbose output suppressed, use -v or -vv for full protocol decode
listening on eth0, link-type EN10MB (Ethernet), capture size 1536 bytes
23:51:57.224344 IP 192.168.1.47.55058 > 218.248.240.23.53: 9959+ A? CW8.(none). (28)
23:51:57.274656 IP 192.168.1.47.39046 > 218.248.240.23.53: 43484+ A? CW8.(none). (28)
What to do?

EDIT: I just found a current LQ thread asking a very similar question, without a solution at the time of writing -- but solved by the OP within the hour.

Best

Charles

Last edited by catkin; 12-16-2009 at 03:57 AM.
 
Old 12-16-2009, 03:56 AM   #2
catkin
LQ 5k Club
 
Registered: Dec 2008
Location: Tamil Nadu, India
Distribution: Debian
Posts: 8,578

Original Poster
Blog Entries: 31

Rep: Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208Reputation: 1208
Solved

My silly mistake in dnsmasq.conf, setting local=/localhost/ instead of local=/localdomain/
 
Old 02-18-2013, 10:50 AM   #3
michal017
Member
 
Registered: Jan 2004
Location: EU
Distribution: Debian
Posts: 90

Rep: Reputation: 15
Did you have to tamper with resolv.conf as well?

What I did is that I:
- added my local hostname to /etc/hosts with and without the .localdomain, e.g.:
1.2.3.4 hostname hostname.localdomain

- added this to my dnsmasq config:
expand-hosts
domain=localdomain
local=/localdomain/

But I still see in dnsmasq log that the query to "hostname" is forwarded to all the nameservers in my resolv.conf.
My resolv.conf contains 127.0.0.1 (dnsmasq runs here) and 2 other IPs given by the ISP provider.
 
  


Reply

Tags
dnsmasq, domain, hosts, local



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to prevent certain hosts from accessing my web page... trist007 Linux - Newbie 1 01-19-2009 11:21 PM
How to setup nslookups, queries using /etc/hosts as the default cornsnap Linux - Server 4 07-10-2008 08:21 PM
Verify /etc/hosts usage and round robin in /etc/hosts MikeyCarter Linux - Software 1 06-24-2008 12:20 PM
can't restrict sshd access through hosts.allow and hosts.deny but was working earlier farhan Linux - Security 4 04-18-2008 07:41 AM
DNSMASQ Wont expand hosts Rooboy Linux - Networking 1 01-18-2005 10:02 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Networking

All times are GMT -5. The time now is 04:43 PM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration