@IPNAME (and more)

  • This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.
Using @IPNAME on my internet address ...

v:\> echo %_ip

v:\> echo %@ipname[]
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:

#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:  ""
    wsprintf(szNameBuf, "%s.in-addr.arpa", inet_ntoa(address));
    PDNS_RECORD pDnsRecord;

    DNS_STATUS dnsResult = DnsQuery(szNameBuf, DNS_TYPE_PTR, 
            | DNS_QUERY_NO_NETBT
            | DNS_QUERY_WIRE_ONLY,
            &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.
(Chapter 2)

When I use SENDMAIL ...

Connection from, Sat Jun 20 12:27:40 2009
MAIL FROM: <vefatica@vefatica.net>
RCPT TO:<vefatica@lucky.syr.edu>
DATA - 7 lines, 177 bytes.
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:

Connection from, Sat Jun 20 12:27:40 2009
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.