@IPNAME (and more)

May 20, 2008
12,170
133
Syracuse, NY, USA
Using @IPNAME on my internet address ...

Code:
v:\> echo %_ip
72.230.122.241 192.168.1.3 169.254.1.2

v:\> echo %@ipname[72.230.122.241]
ZZ.twcny.rr.com
That's a meaningless and useless (doesn't work with Winsock functions) combination of my computer's "given" name and LocalAreaConnection2's "Primary and connection-specific DNS suffixes".

Once upon a time (pre-W2K?), gethostbyaddr() (and related functions) would cause a DNS lookup and give the actual internet name of my computer, but no longer. According to a seemingly knowledgeable gent in microsoft.public.win32.programmer.network the computer's public address is considered local and you cannot get gethostbyaddr(), WSAAsyncGetHostByAddr(), or getnameinfo() to do a real lookup. All three functions give the same bogus name.

Recommend, for W2K and later:

Code:
#define IsRoutable(X,Y) \
    (!(X==10 || (X==192 && Y==168) || (X==172 && (Y&240)==16) || (X==169 && Y==254) ))

    /* do the lookup for routable IP */
    CHAR szNameBuf[32];
    /* address in already in network order */
    /* backwards, e.g., jpsoft:  "219.19.242.66.in-addr.arpa"
    wsprintf(szNameBuf, "%s.in-addr.arpa", inet_ntoa(address));
    PDNS_RECORD pDnsRecord;

    DNS_STATUS dnsResult = DnsQuery(szNameBuf, DNS_TYPE_PTR, 
            DNS_QUERY_BYPASS_CACHE
            | DNS_QUERY_NO_HOSTS_FILE
            | DNS_QUERY_NO_LOCAL_NAME
            | DNS_QUERY_NO_NETBT
            | DNS_QUERY_WIRE_ONLY,
            NULL,
            &pDnsRecord, NULL);

    if ( dnsResult == NO_ERROR  )
    {
        wsprintf(szName, "%s", pDnsRecord->Data.PTR.pNameHost);
        DnsRecordListFree(pDnsRecord, DnsFreeRecordListDeep);
    }

I have more robust code that does GetBestInterface() and creates a list of DNS servers to give DnsQuery() (instead of NULL) but, at least on XP, that seems to be DnsQuery()'s default behavior.

To be continued.
 
May 20, 2008
12,170
133
Syracuse, NY, USA
(Chapter 2)

When I use SENDMAIL ...

Code:
Connection from 72.230.122.241, Sat Jun 20 12:27:40 2009
EHLO ZZ
RSET
MAIL FROM: <vefatica@vefatica.net>
RCPT TO:<vefatica@lucky.syr.edu>
DATA
DATA - 7 lines, 177 bytes.
QUIT
1 sec. elapsed, connection closed Sat Jun 20 12:27:41 2009

(1) the RSET is unnecessary and looks suspiciously like something a spammer would do.

(2) the EHLO (HELO) name, "ZZ", is not a very good internet name and I think an SMTP client should strive to provide a valid lookup-able name. My server, perhaps others, discriminate on that name. If my IP were not exempt from transaction-level filtering, that log would have looked like this:

Code:
Connection from 72.230.122.241, Sat Jun 20 12:27:40 2009
EHLO ZZ
554 Not authorized
1 sec. elapsed, connection closed Sat Jun 20 12:27:41 2009

If you're in control, I'd recommend using a real name (from DnsQuery()). If you're not in control you might mention this to IPWORKS.
 

Similar threads

M
Replies
0
Views
2K
Support
mathewsdw@sbcglobal.net
M