Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 27th, 2006, 11:25 PM   #1
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
domain existence

How could I check if a DNS domain exists? dig doesn't work because my DNS servers (OpenDNS) return the IP of their search server.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Sep 28th, 2006, 3:27 PM   #2
jim mcnamara
Hobbyist Programmer
 
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4 jim mcnamara is on a distinguished road
Do you want to check the existence of any domain - nslookup?
Options let you specify a domain to limit the search. You can also specify the
DNS box.

I'm not sure what you meant by a DNS domain in this context....
jim mcnamara is offline   Reply With Quote
Old Sep 28th, 2006, 6:34 PM   #3
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
nslookup isn't what I want, but its man page pointed me to host, which is exactly what I wanted.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Sep 29th, 2006, 12:54 AM   #4
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
:/ host doesn't handle LAN IPs or aliases in /etc/hosts.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Sep 29th, 2006, 12:19 PM   #5
sarumont
Hobbyist Programmer
 
sarumont's Avatar
 
Join Date: Apr 2004
Location: /dev/urandom
Posts: 154
Rep Power: 5 sarumont is on a distinguished road
Send a message via ICQ to sarumont Send a message via AIM to sarumont Send a message via Yahoo to sarumont
Check out 'man gethostbyname'. I believe that this library uses the standard DNS lookup stack in *nix (typically in /etc/host.conf).
__________________
"Time is an illusion. Lunchtime doubly so."
-the late, great Douglas Adams
sarumont is offline   Reply With Quote
Old Sep 29th, 2006, 6:50 PM   #6
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Umm... this is the shell forum, not the C forum.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Oct 3rd, 2006, 10:11 AM   #7
sarumont
Hobbyist Programmer
 
sarumont's Avatar
 
Join Date: Apr 2004
Location: /dev/urandom
Posts: 154
Rep Power: 5 sarumont is on a distinguished road
Send a message via ICQ to sarumont Send a message via AIM to sarumont Send a message via Yahoo to sarumont
Quote:
Originally Posted by a thing View Post
Umm... this is the shell forum, not the C forum.
If the problem cannot be solved with existing shell tools, then you may need to write your own.

If you just simply want to see if a domain name resolves, you can use something like:

ping $DOMAIN -c1 | grep ^PING | \
awk -F\  '{ gsub( /\(/,// , $3); gsub( /\)/,//,$3 ); print $3 }'

That returns the IP address of the domain. If the domain does not resolve, you get:

ping: unknown host googlaoeuaoee.com

If you do not care what the IP is, you can simply use ping:

#!/bin/bash

ping -c1 $1 >> /dev/null

if [ $? == 2 ]; then
    echo "$1 does not exist."
else
    echo "$1 exists."
fi

Hope this helps.
__________________
"Time is an illusion. Lunchtime doubly so."
-the late, great Douglas Adams
sarumont is offline   Reply With Quote
Old Oct 3rd, 2006, 8:11 PM   #8
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Quote:
Originally Posted by me
my DNS servers (OpenDNS) return the IP of their search server
notroot@arthur[0:~]$ ping -c1 asdr.ear.baawer
PING asdr.ear.baawer (208.67.219.40) 56(84) bytes of data.
64 bytes from ip-208-67-219-40.n.opendns.com (208.67.219.40): icmp_seq=1 ttl=50 time=14.1 ms

--- asdr.ear.baawer ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 14.197/14.197/14.197/0.000 ms
notroot@arthur[0:~]$ echo $?
0
notroot@arthur[0:~]$
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.
a thing is offline   Reply With Quote
Old Oct 3rd, 2006, 10:17 PM   #9
sarumont
Hobbyist Programmer
 
sarumont's Avatar
 
Join Date: Apr 2004
Location: /dev/urandom
Posts: 154
Rep Power: 5 sarumont is on a distinguished road
Send a message via ICQ to sarumont Send a message via AIM to sarumont Send a message via Yahoo to sarumont
Quote:
Originally Posted by a thing View Post
notroot@arthur[0:~]$ ping -c1 asdr.ear.baawer
PING asdr.ear.baawer (208.67.219.40) 56(84) bytes of data.
64 bytes from ip-208-67-219-40.n.opendns.com (208.67.219.40): icmp_seq=1 ttl=50 time=14.1 ms

--- asdr.ear.baawer ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 14.197/14.197/14.197/0.000 ms
notroot@arthur[0:~]$ echo $?
0
notroot@arthur[0:~]$
That clears things up a bit. Whether the domain exists or not has no bearing on OpenDNS's reply. That is quite crappy. Short of using your own DNS servers (or your ISP's), putting two and two together should work for you:

-'host' can resolve the IP of any FQDN given it
-'ping' can resolve the IP of any local DN (that you may specify in /etc/hosts)

host + ping + glue = solution

Edit:

Playing around a bit more with OpenDNS as my nameserver, it appears to only return its search server IPs when the domain is not found. This being the case, you can still solve this with one tool (ping) and some parsing of the results (if $IP is in $IPS_OWNED_BY_OPENDNS....).
__________________
"Time is an illusion. Lunchtime doubly so."
-the late, great Douglas Adams
sarumont is offline   Reply With Quote
Old Oct 3rd, 2006, 10:38 PM   #10
a thing
Unverified User
 
a thing's Avatar
 
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0 a thing is on a distinguished road
Your proposed solution has given me a better idea. Ping gives the packet loss percent. All I need to do is check if that's like <=15.

Damn I should learn awk.
__________________
Warning: My posts may change (dramatically) within the first 15 minutes they're posted.
Got 'Nux?—GNU/Linux and other free software support.
It's GNU/Linux, not just Linux.

Last edited by a thing; Oct 3rd, 2006 at 10:59 PM.
a thing is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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 On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Signing up for a domain name Harakim Coder's Corner Lounge 29 May 17th, 2006 9:17 AM
Domain Object Validation hoffmandirt Software Design and Algorithms 5 Apr 28th, 2006 6:39 PM
Domain Name/Trademark Infringment ║▓ßúdhαrlεy▓║ Other Web Development Languages 13 Jul 9th, 2005 12:23 PM
domain name search Alex C D1DJ HTML / XHTML / CSS 9 Jun 24th, 2005 4:15 AM
Net Group /ADD (on a windows box, non domain controller) Infinite Recursion Other Programming Languages 1 Apr 13th, 2005 2:27 PM




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:32 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC