bind server problem

Discussion in 'Linux Networking' started by Julien Mills, May 22, 2012.

  1. Julien Mills

    Julien Mills Guest

    Hey all,

    I have a caching bind dns (and dhcpd) server running on a Slackware box.
    It works great, almost.

    My website is hosted off-site.

    In a browser when I type: www.example.com it works, I get to my website.
    If I type example.com (without the www) it does not work.

    Does anyone know how I can set up the dns to make this work?

    Thanks
     
    Julien Mills, May 22, 2012
    #1
    1. Advertisements

  2. Julien Mills

    Jorgen Grahn Guest

    Do you want example.com to resolve only when you use your caching name
    server, or do you want it to work for everyone, from anywhere? I'm
    pretty sure a caching-only name server can't make the latter happen.

    /Jorgen
     
    Jorgen Grahn, May 22, 2012
    #2
    1. Advertisements

  3. Julien Mills

    Whiskers Guest

    Have you got an entry specifically for www.example.com but not for the
    general example.com?
     
    Whiskers, May 22, 2012
    #3
  4. Julien Mills

    Julien Mills Guest

    Not quite sure what you mean. I want it work for all our users behind our
    firewall. Our dns server is only available locally. Is that what you
    mean?

    Thanks,

    Julein
     
    Julien Mills, May 23, 2012
    #4
  5. Julien Mills

    Julien Mills Guest

    There's an entry for www and an entry for example.com.

    www A 100.10.11.12
    example.com A 100.10.11.12

    I believe that bind automatically put them in there, is that possible?

    Just did a little testing, from a Windows machine here on our network
    www.example.com works, example.com does not. This makes no sense to me.

    I want both to work, mainly because Google is returning example.com so I
    want that to work.
     
    Julien Mills, May 23, 2012
    #5
  6. Julien Mills

    Jorgen Grahn Guest

    Yes, that was what was unclear. The part about users behind a firewall
    was missing from the original question.

    /Jorgen
     
    Jorgen Grahn, May 23, 2012
    #6
  7. Julien Mills

    Joe Pfeiffer Guest

    Unless you've got a good reason to use bind I highly recommend switching
    to dnsmasq. It's roughly an order of magnitude easier to configure.

    As to your particular problem, it's hard to guess what's going on from
    two lines plucked from your config file. But, if those two lines are
    really next to each other, I'm guessing they're inside a zone defined
    for example.com. If I'm right in that guess, you've defined resource
    records for www.example.com. and example.com.example.com. If you
    replace the second line with

    @ A 100.10.11.12

    it should work (the @ says 'use the root of the domain').

    Also, if you'd used

    example.com. A 100.10.11.12

    (note the period after the hostname) is would have worked.
     
    Joe Pfeiffer, May 23, 2012
    #7
  8. Julien Mills

    Chris Davies Guest

    What do you mean by "it does not work"? There are at least two different
    potential issues here.

    1. DNS entries: is there a DNS 'A' record for both www.example.com
    and example.com, and do both resolve to the same IP address. (This
    is what the other posts here seem to be concentrating on.)

    2. Web configuration: many websites these days are configured to be
    able to run multiple websites from the same IP address. Consequently,
    unless you tell the webserver to accept requests for www.example.com
    AND example.com, it won't have any content to deliver to you.

    You can confirm #1 by running the following commands and visually
    confirming that you get the same external address reported for both
    questions:

    dig +short a www.example.com
    dig +short a example.com

    You can confirm #2 either by checking the configuration files for your
    webserver, or empirically as follows. First, you need to obtain the
    correct IP address for your server. In this example I'm going to assume
    it's 10.11.12.13:

    (a)

    nc -vvv 10.11.12.13 80 # "telnet 10.11.12.13 80"
    GET / HTTP/1.0
    Host: www.example.com

    (b)
    nc -vvv 10.11.12.13 80
    GET / HTTP/1.0
    Host: example.com

    In both cases you'll need to hit Return a couple of times at the end
    (i.e. there needs to be a blank line after the Host: line).

    If you get the same content from both requests then your web server is
    configured as you hope. If you don't then it isn't.

    Chris
     
    Chris Davies, May 24, 2012
    #8
  9. Julien Mills

    Julien Mills Guest

    Joe,
    You are exactly correct in everything you say here, your guesses and
    conclusions. Both of your solutions work perfectly.

    Thank you very much. I am so glad to get this going.

    Thanks again.
     
    Julien Mills, May 24, 2012
    #9
  10. Julien Mills

    Julien Mills Guest

    Chris,

    Thank you for this helpful answer. It turns out my problem is #1, dns
    entries for my web site were not working, Joe helped me fix that. I like
    the "+short a", makes it neater.

    And I ran your tests for #2, it turns out the web site is configured to
    handle both cases properly which is good to know. Thanks for those
    tests. nc is very useful.


    Julien
     
    Julien Mills, May 24, 2012
    #10
  11. Julien Mills

    Chris Davies Guest

    No problem.

    Nc (aka netcat) is a very powerful tool for building or testing network
    connections. It's worth taking a look at its capabilities (don't aim
    to memorise the manual though!) so you know what's possible. Socat is
    another really useful network tool, but IMO the syntax is complex and
    really hard to get one's head around.

    Chris
     
    Chris Davies, May 24, 2012
    #11
  12. Julien Mills

    Joe Pfeiffer Guest

    You're very welcome!
     
    Joe Pfeiffer, May 25, 2012
    #12
    1. Advertisements

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments (here). After that, you can post your question and our members will help you out.