473,796 Members | 2,690 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

If gethostbyname fails it never recovers

I've been having problems with my ISP. One way it seems to manifest
itself is that I can not reach or contact my ISP's DNS servers. IOW a
simply nslookup google.com will fail.

So I tried writing a script that would monitor this. The script calls
gethostbyname for google.com every 15 minutes and logs the status. When
gethostbyname fails however it never comes back. My ISP and internet
connection may come back and nslookup at the command line will work
fine. But my script will report failure at the next and following 15
minute intervals. This is very unexpected. What am I doing wrong and is
there a way to "reset" things so that it will start working again.

Here's a snippet:

sub CheckDNS {
my $host = shift;

my @ipaddrs = gethostbyname $host;
my $status = $?;

if ($status ne 0 and $debug) {
debug "Host: $host ($status)";
} # if

return $status
} # CheckDNS

CheckDNS is called every 15 minutes with "google.com " as a parm. When a
failure happens $status = 2 and remains = 2 forever.

--

Andrew DeFaria <http://defaria.com>
Dain bramaged.

Oct 5 '06 #1
2 5580
>>>>"Andrew" == Andrew DeFaria <An****@DeFaria .comwrites:

AndrewSo I tried writing a script that would monitor this. The script calls
Andrewgethostby name for google.com every 15 minutes and logs the status. When
Andrewgethostby name fails however it never comes back. My ISP and internet
Andrewconnectio n may come back and nslookup at the command line will work fine. But
Andrewmy script will report failure at the next and following 15 minute
Andrewintervals . This is very unexpected. What am I doing wrong and is there a way
Andrewto "reset" things so that it will start working again.

AndrewHere's a snippet:

Andrewsub CheckDNS {
Andrew my $host = shift;

Andrew my @ipaddrs = gethostbyname $host;
Andrew my $status = $?;

Andrew if ($status ne 0 and $debug) {
Andrew debug "Host: $host ($status)";
Andrew } # if

Andrew return $status
Andrew} # CheckDNS

AndrewCheckDNS is called every 15 minutes with "google.com " as a parm. When a
Andrewfailure happens $status = 2 and remains = 2 forever.

$? is not set for a gethostbyname failure. In fact, I'm not sure
anything is actually set.

And now a word from our Usenet manager...

If you can see this message, you are reading a group that is not
officially carried, and therefore doesn't get the propogation or
readership that the official comp.lang.perl. misc group gets.

What this means TO YOU is that your question won't be answered
to the same expert level that an official group will get. You'll
get answers that are wrong (and not noticed to be wrong), or no
answer at all.

STOP POSTING HERE. POST TO COMP.LANG.PERL. MISC

And send email to your news server administrator to PLEASE DELETE THIS
GROUP.

--
Randal L. Schwartz - Stonehenge Consulting Services, Inc. - +1 503 777 0095
<me****@stonehe nge.com<URL:htt p://www.stonehenge. com/merlyn/>
Perl/Unix/security consulting, Technical writing, Comedy, etc. etc.
See PerlTraining.St onehenge.com for onsite and open-enrollment Perl training!

--
Posted via a free Usenet account from http://www.teranews.com

Oct 5 '06 #2
Randal L. Schwartz wrote:
$? is not set for a gethostbyname failure. In fact, I'm not sure
anything is actually set.
Actually, at least on my system... it is! If I change $host = "bogus"
gethostbyname sets $? to 1. Try it!
And now a word from our Usenet manager...

If you can see this message, you are reading a group that is not
officially carried, and therefore doesn't get the propogation or
readership that the official comp.lang.perl. misc group gets.

What this means TO YOU is that your question won't be answered to the
same expert level that an official group will get. You'll get answers
that are wrong (and not noticed to be wrong), or no answer at all.

STOP POSTING HERE. POST TO COMP.LANG.PERL. MISC

And send email to your news server administrator to PLEASE DELETE THIS
GROUP.
Thanks. I had no idea. I will post there...

--

Andrew DeFaria <http://defaria.com>
I got a new shadow. I had to get rid of the other one -- it wasn't doing
what I was doing.

Oct 6 '06 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
6637
by: yawnmoth | last post by:
using the gethostbyname function seems to noticeably slow down pages. some of the comments in php.net's gethostbyname entry suggest using a version that caches the result, but those versions also only speedup subsequent calls to gethostbyname - the first call is still as slow as ever. so is there anything i can do to speed this up? perhapes i can just implement a function equivalent to gethostbyname using fsockopen, or something?
0
6037
by: Eric Brunel | last post by:
Hi all, I just compiled Python 2.3.2 on Linux Mandrake 8.0, upgrading from Python 2.1. I have one problem that I can't figure out: when I wanted to get "the" IP address of the current host with Python 2.1, I did: Python 2.1.1 (#12, Apr 10 2002, 17:52:08) on linux2 Type "copyright", "credits" or "license" for more information. >>> import socket
1
7148
by: Fortepianissimo | last post by:
I've tried using socket.setdefaulttimeout(timeout) to set the default timeout to 'timeout' for all sockets. The part that's not clear to me, is that if this will affect socket.gethostbyname(). In my observation the timeout setting did not affect the DNS lookup. It might be my misunderstanding of the semantics here: would
5
2744
by: ruroma | last post by:
Hello, I have one problem, and can think of two possible solutions but I can't manage to make them work. I'm open to other suggestions if you thik is better. The main function calls sendSocket, but I don't know how to tell it where to send the socket. ( I think I'm messing it up with pointers)
1
3815
by: Glen Conway | last post by:
Hi, I'm trying to use the gethostbyname function from wsock32.dll and failing dismally Has anyone got a successful implementation of this in VB.NET? My ulitimate goal is to resolve NetBIOS names to IP Addresses. I can use the framework DNS features if a DNS server is present on the network but this cannot use WINS if no DNS server is available. Any help or pointers are apprecatiated. Here is the code I've managed to do so far. I've...
1
7226
by: Quentin Carbonneaux | last post by:
Hello, I'm writing a little program which has to get a FQDN on his stdin and return the IP on stdout, we can do it easily with gethostbyname call but I would like to set up a timeout to this blocking system call. So I read texts about this and I planed to use a hack with alarm and setjmp/longjmp. My program works until there is a timeout, when it occurs, all the gethostbyname calls which follow fail, backtrace in gdb give me this : #0 ...
1
1728
by: yawnmoth | last post by:
I seem to be getting conflicting gethostbyname behavior on different servers. Before going into detail, here's the script I'm using: <? $address = $HTTP_SERVER_VARS; $rev = implode('.',array_reverse(explode('.', $address))); $lookup = "$rev.l1.spews.dnsbl.sorbs.net"; echo gethostbyname($lookup); echo '<br />';
18
3664
by: aj | last post by:
I have the following snippet of code. On some platforms, the delete calls works, on Linux, it core dumps (memory dump) at the delete call. Am I responsible for deleting the memory that gethostbyname allocated? struct hostent *lHostInfo; lHostInfo = gethostbyname(ipHost.c_str()); memcpy(&(lDestAddr.sin_addr), lHostInfo->h_addr_list, lHostInfo- delete lHostInfo;
6
6858
by: cpptutor2000 | last post by:
Could some C guru please help ? I am writing a Web server on RH 9.0 box. In the section of the code where the Web server has to be initiialized, I have: char host; struct hostent *hp = NULL; .............................. ............................... if(gethostname(host, sizeof(host)) < 0) {
0
9679
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9527
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10453
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10223
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10172
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10003
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7546
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6785
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.