nslookup/config question

Discussion in 'Ruby' started by Frank Goodman, Sep 19, 2005.

  1. Apologies in advance if this is the wrong place to post, appreciate any
    pointers to the right place if I've polluted the wrong thread

    Specifics:
    ruby 1.8.2 (2004-12-25) [i686-linux]
    Host: Linux gentoo 2.6.12

    My linux box does not run a nameserver, as it is a home machine that I use
    for development. I connect to the internet through a Dlink router and
    cable-modem.

    When I do a Socket/TCPSocket.gethostbyname call from within ruby, for
    "unknown" hosts it returns an array that corresponds to my DynDNS domain name
    with my "public IP address"

    When I run `nslookup` it returns:

    ** server can't find foo.foobar.frt: NXDOMAIN

    With the socket version it is more complicated for me to determine bad hosts
    and I certainly can't do it in a portable way, so I'd like to set things up so
    the Ruby.Socket code returns a proper error.

    I'm guessing this has something to do with my (improper) configuration of my
    system or router. Any help would be appreciated

    I am curious why I would get different behaviours from the Ruby gethostbyname
    and nsslookup which I would imagine should resolve down to a gethostbyname
    call as well.

    Ideas?

    Again, apologies if I've posted to the wrong place.

    --
    Frank Goodman
    mailto:
    Frank Goodman, Sep 19, 2005
    #1
    1. Advertising

  2. Frank Goodman

    Eric Hodel Guest

    On 19 Sep 2005, at 13:26, Frank Goodman wrote:

    > Apologies in advance if this is the wrong place to post, appreciate
    > any
    > pointers to the right place if I've polluted the wrong thread
    >
    > Specifics:
    > ruby 1.8.2 (2004-12-25) [i686-linux]
    > Host: Linux gentoo 2.6.12
    >
    > My linux box does not run a nameserver, as it is a home machine
    > that I use
    > for development. I connect to the internet through a Dlink router and
    > cable-modem.
    >
    > When I do a Socket/TCPSocket.gethostbyname call from within ruby, for
    > "unknown" hosts it returns an array that corresponds to my DynDNS
    > domain name
    > with my "public IP address"
    >
    > When I run `nslookup` it returns:
    >
    > ** server can't find foo.foobar.frt: NXDOMAIN
    >
    > With the socket version it is more complicated for me to determine
    > bad hosts
    > and I certainly can't do it in a portable way, so I'd like to set
    > things up so
    > the Ruby.Socket code returns a proper error.
    >
    > I'm guessing this has something to do with my (improper)
    > configuration of my
    > system or router. Any help would be appreciated
    >
    > I am curious why I would get different behaviours from the Ruby
    > gethostbyname
    > and nsslookup which I would imagine should resolve down to a
    > gethostbyname
    > call as well.
    >
    > Ideas?


    I don't think this is a ruby issue...

    $ nslookup foo.foobar.frt
    Server: 192.168.1.15
    Address: 192.168.1.15#53

    ** server can't find foo.foobar.frt: NXDOMAIN

    $ ruby -rsocket -e 'Socket.gethostbyname("foo.foobar.frt")'
    -e:1:in `gethostbyname': getaddrinfo: hostname nor servname provided,
    or not known (SocketError)
    from -e:1

    Ruby uses the libc resolver to look up domain names. (I forget if
    nslookup uses libc or its own builtin resolver... host does under OS X.)

    Try also the pure-ruby DNS resolver:

    $ ruby -rresolv -e 'p Resolv.getaddress("foo.foobar.frt")'
    /usr/local/lib/ruby/1.8/resolv.rb:89:in `getaddress': no address for
    foo.foobar.frt (Resolv::ResolvError)
    from /usr/local/lib/ruby/1.8/resolv.rb:39:in `getaddress'
    from -e:1


    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Sep 20, 2005
    #2
    1. Advertising

  3. Frank Goodman

    Eric Hodel Guest

    On 19 Sep 2005, at 16:49, Eric Hodel wrote:

    > On 19 Sep 2005, at 13:26, Frank Goodman wrote:
    >
    >
    >> Apologies in advance if this is the wrong place to post,
    >> appreciate any
    >> pointers to the right place if I've polluted the wrong thread
    >>
    >> Specifics:
    >> ruby 1.8.2 (2004-12-25) [i686-linux]
    >> Host: Linux gentoo 2.6.12
    >>
    >> My linux box does not run a nameserver, as it is a home machine
    >> that I use
    >> for development. I connect to the internet through a Dlink router and
    >> cable-modem.
    >>
    >> When I do a Socket/TCPSocket.gethostbyname call from within ruby, for
    >> "unknown" hosts it returns an array that corresponds to my DynDNS
    >> domain name
    >> with my "public IP address"
    >>
    >> When I run `nslookup` it returns:
    >>
    >> ** server can't find foo.foobar.frt: NXDOMAIN
    >>
    >> With the socket version it is more complicated for me to determine
    >> bad hosts
    >> and I certainly can't do it in a portable way, so I'd like to set
    >> things up so
    >> the Ruby.Socket code returns a proper error.
    >>
    >> I'm guessing this has something to do with my (improper)
    >> configuration of my
    >> system or router. Any help would be appreciated
    >>
    >> I am curious why I would get different behaviours from the Ruby
    >> gethostbyname
    >> and nsslookup which I would imagine should resolve down to a
    >> gethostbyname
    >> call as well.
    >>
    >> Ideas?
    >>

    >
    > I don't think this is a ruby issue...
    >
    > $ nslookup foo.foobar.frt
    > Server: 192.168.1.15
    > Address: 192.168.1.15#53
    >
    > ** server can't find foo.foobar.frt: NXDOMAIN
    >
    > $ ruby -rsocket -e 'Socket.gethostbyname("foo.foobar.frt")'
    > -e:1:in `gethostbyname': getaddrinfo: hostname nor servname
    > provided, or not known (SocketError)
    > from -e:1
    >
    > Ruby uses the libc resolver to look up domain names. (I forget if
    > nslookup uses libc or its own builtin resolver... host does under
    > OS X.)


    ... host uses its own builtin resolver under OS X ...

    > Try also the pure-ruby DNS resolver:
    >
    > $ ruby -rresolv -e 'p Resolv.getaddress("foo.foobar.frt")'
    > /usr/local/lib/ruby/1.8/resolv.rb:89:in `getaddress': no address
    > for foo.foobar.frt (Resolv::ResolvError)
    > from /usr/local/lib/ruby/1.8/resolv.rb:39:in `getaddress'
    > from -e:1
    >
    >
    > --
    > Eric Hodel - - http://segment7.net
    > FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    >
    >


    --
    Eric Hodel - - http://segment7.net
    FEC2 57F1 D465 EB15 5D6E 7C11 332A 551C 796C 9F04
    Eric Hodel, Sep 20, 2005
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Franco Figún

    NSLOOKUP

    Franco Figún, Aug 4, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    2,984
    Ken Cox [Microsoft MVP]
    Aug 5, 2004
  2. gethostbyaddr/nslookup failed

    , Jul 27, 2005, in forum: C Programming
    Replies:
    1
    Views:
    548
    Artie Gold
    Jul 27, 2005
  3. Joe Snodgrass

    Nslookup

    Joe Snodgrass, May 16, 2011, in forum: C++
    Replies:
    35
    Views:
    987
    thingamabob
    May 20, 2011
  4. Joe Snodgrass

    Nslookup

    Joe Snodgrass, May 16, 2011, in forum: Java
    Replies:
    47
    Views:
    1,385
    Michael Doubez
    May 20, 2011
  5. TomT

    ASP Web Based nslookup

    TomT, Jun 12, 2004, in forum: ASP General
    Replies:
    6
    Views:
    286
    Anthony
    Aug 6, 2004
Loading...

Share This Page