locked
How to Retrieve Current Network Interface Setting DNS Server IP List in Windows Store APP

    Question

  • I'm trying to implement a function just like ipconfig command that allow me to get DNS server ip list of current network interface in Windows Store APP in C++.

    But I can't find any Windows Runtime APIs on MSDN to achieve this goal.

    My question is:

    Is it able to get current DNS server ip list by Windows Runtime APIs?

    Monday, March 04, 2013 2:26 AM

Answers

  • Hello,

    Regarding: "1.2 How does this API get the remote host name (or IP addr)? does it really send UDP packets to the destination? If yes, does it send UDP packets only by the "remoteServiceName" parameter I addressed to the API or it will try ALL possible ports of the destination?"

    The DatagramSocket.GetEndpointPairsAsync function calls into GetAddrInfoEx so when you set the value "0" it does not mean that all ports/services will be scanned. All of the documentation of GetAddrInfoEx applies to this functionality!

    I hope that helps.

    Thanks,

    Prashant.

    Friday, March 08, 2013 2:56 AM
    Moderator

All replies

  • I'm considering another solution for my previous question.

    My final goal is to implement an IP resolver function like getaddrinfo() win32 API.

    Because I already implement DNS protocol by UDP socket, the only thing I need is DNS IP for domain name query.


    But I find another Windows Runtime API: DatagramSocket.GetEndpointPairsAsync()

    MSDN: http://msdn.microsoft.com/zh-tw/library/windows/apps/hh701245.aspx

    It gets a list of EndpointPair objects based on a remote hostname and remote service name that can be used to send datagrams to a remote network destination.


    My questions will be:

    1. Can I use this API as IP resolver function?

        1.1 The remoteHostName property of EndpointPair class can be "The hostname" or "IP address" according to MSDN, so it might return domain name back even I pass a domain name to the API?

        1.2 How does this API get the remote host name (or IP addr)? does it really send UDP packets to the destination? If yes, does it send UDP packets only by the "remoteServiceName" parameter I addressed to the API or it will try ALL possible ports of the destination?

    2. Same as my original question, is it able to get current DNS server IP list by Windows Runtime APIs?


    Monday, March 04, 2013 7:16 AM
  • You can use DispalyName in HostName to get the domain name and use IPInofrmation to get IP address.

    As far as I know, this API need to send UDP first and then get the ip information.

    Here is two way to get these information, please check this thread
    http://social.msdn.microsoft.com/Forums/et-EE/winappswithcsharp/thread/4939e87b-0fcb-42c1-89e6-9d78811fbeea

    Best regards,
    Jesse


    Jesse Jiang
    MSDN Community Support | Feedback to us
    Develop and promote your apps in Windows Store
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    Tuesday, March 05, 2013 2:41 AM
  • HI Jesse,

    Thanks for your reply.

    The reason of my question #1.2 "Will DatagramSocket.GetEndpointPairsAsync() try to scan ALL possible ports(services) of the destination" is base on security concern.

    If it does so (try to scan all possible ports/services), some of the service suppliers might regard this behavior as hacking and block my UDP packet for getting IP information from the destination.

    Currently I've tried passing port "0" to the "remoteServiceName" parameter to resolve IP addr of some domain (i.e. microsoft.com, www.google.com, www.yahoo.com...ect) and it works just fine, but I'm worry about the behavior of this API might be marked as malicious.

    Can you help to confirm if the API acts like my description or not? Thanks again!

    Tuesday, March 05, 2013 3:29 AM
  • Hello,

    Regarding: "1.2 How does this API get the remote host name (or IP addr)? does it really send UDP packets to the destination? If yes, does it send UDP packets only by the "remoteServiceName" parameter I addressed to the API or it will try ALL possible ports of the destination?"

    The DatagramSocket.GetEndpointPairsAsync function calls into GetAddrInfoEx so when you set the value "0" it does not mean that all ports/services will be scanned. All of the documentation of GetAddrInfoEx applies to this functionality!

    I hope that helps.

    Thanks,

    Prashant.

    Friday, March 08, 2013 2:56 AM
    Moderator