![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#2 |
|
Hobbyist Programmer
Join Date: Jun 2005
Location: New Mexico
Posts: 228
Rep Power: 4
![]() |
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.... |
|
|
|
|
|
#3 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#4 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
:/ 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. |
|
|
|
|
|
#5 |
|
Hobbyist Programmer
|
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 |
|
|
|
|
|
#6 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
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. |
|
|
|
|
|
#7 |
|
Hobbyist Programmer
|
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."
fiHope this helps. ![]()
__________________
"Time is an illusion. Lunchtime doubly so." -the late, great Douglas Adams |
|
|
|
|
|
#8 | |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
Quote:
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. |
|
|
|
|
|
|
#9 | |
|
Hobbyist Programmer
|
Quote:
-'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 |
|
|
|
|
|
|
#10 |
|
Unverified User
Join Date: Aug 2005
Location: none
Posts: 146
Rep Power: 0
![]() |
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. |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
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 |