Performing a DNS Lookup

Posted on 2004-11-24
Last Modified: 2012-05-05

I am writing a mailer as part of a personal project for the purpose of sending out verification emails when a user creates an account on my server.

To do this, I need to retrieve the MX records for the destination hosts.  I have spent ages reading through all the relevant RFCs but one simple piece of information eludes me: How the hel do you connect to a DNS server in the first place ??

I know it use port 53 but what IP address do you use?  Is it assigned by the ISP and if so how do you find it?

My software is intended for windows and should work on all versions of it.  I'm writing everything from scratch including the HTTP and SMTP services so I really need to know how to connect to the DNS instead of using some obscure function that I dont understand.
Question by:LordWolfy
    LVL 3

    Accepted Solution


    The DNS address is often ISP specific and assinged by the ISP as a network property. So can be found out by checking the address in  the TCP/IP properties. Often this may be something that is autoconfigured so this information is fetched from the DHCP server. The best option, leave the IP of the DNS as a configurable item which the clients can enter after consulting their ISP

    Aftewr that, u can open a TCP or UDP socket at the configured IP and port 53 and connect to the DNS server. On connection, just send the message, formatted with appropriate fields, as mentioned in the RFC 1035. And to this the server would respond in the required format sending u lla the information you need.

    You need look up information on what data u need to send down the socket and what kind of response would u recieve. the creating and parsing of sent and recieved messages is then a programmable task.

    this would help u find more information on implementing the protocol.

    LVL 19

    Assisted Solution

    LVL 2

    Author Comment


    Found what I was looking for : The function GetNetworkParams in IPHLPAPI.DLL

    I'll split the points between you because the answers are still informative.

    Featured Post

    Looking for New Ways to Advertise?

    Engage with tech pros in our community with native advertising, as a Vendor Expert, and more.

    Join & Write a Comment

    This article is meant to give a basic understanding of how to use R Sweave as a way to merge LaTeX and R code seamlessly into one presentable document.
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    An introduction to basic programming syntax in Java by creating a simple program. Viewers can follow the tutorial as they create their first class in Java. Definitions and explanations about each element are given to help prepare viewers for future …
    In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …

    745 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    21 Experts available now in Live!

    Get 1:1 Help Now