We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

How to Resolve Domain IP?

I refering to sample code and make my one like below. How can I retrieve IP from ResourceRecord?

Dim client As New DnsClient

Dim mxQuestion As Question = New Question("avivainvestors.com", QueryType.MX)

Dim lic As New Aspose.Network.License

lic.SetLicense("C:\Aspose.Total.lic")

Dim serverList As String() = {"218.102.32.208", "203.198.23.208"}

client.DnsServers = serverList

If client.Resolve(mxQuestion) Then

For Each record As ResourceRecord In client.ReceivedMessage.Answers

' Me.TextBox2.Text &= record.ToString

Debug.WriteLine("How can I get the IP?")

Next

End If

Hi,

Thanks for considering Aspose.

For getting the IP address, query type of “A” need to be set. The sample code is below:

Dim client As New DnsClient
Dim mxQuestion As Question = New Question(“www.yahoo.com”, QueryType.A)
'Dim lic As New Aspose.Network.License
'lic.SetLicense(“C:\Aspose.Total.lic”)
'Dim serverList As String() = {“218.102.32.208”, “203.198.23.208”}
'client.DnsServers = serverList
If client.Resolve(mxQuestion) Then
For Each record As ResourceRecord In client.ReceivedMessage.Answers
Dim arecord As AResourceRecord = TryCast(record, AResourceRecord)
If Not arecord Is Nothing Then
Console.WriteLine("IP Address: " & arecord.Address.ToString())
End If
Debug.WriteLine(“How can I get the IP?”)
Next
End If

What I want to do is to get the mail server of a domain. That's why I put MX as QueryType. If I do it manually, I will perform below steps, so what should I do if I want to use ASPOSE, since I have a lot of email domain to check. Please help.

C:\>nslookup

> set type=MX

> microsoft.com

Server: dns04.netvigator.com
Address: 218.102.32.208

Non-authoritative answer:
microsoft.com MX preference = 10, mail exchanger = mail.messaging.microsoft.com

microsoft.com nameserver = ns2.msft.net
microsoft.com nameserver = ns3.msft.net
microsoft.com nameserver = ns4.msft.net
microsoft.com nameserver = ns5.msft.net
microsoft.com nameserver = ns1.msft.net
ns1.msft.net internet address = 65.55.37.62
ns2.msft.net internet address = 64.4.59.173
ns3.msft.net internet address = 213.199.161.77
ns4.msft.net internet address = 207.46.75.254
ns5.msft.net internet address = 65.55.226.140
> exit

C:\>ping mail.messaging.microsoft.com

Pinging mail.messaging.microsoft.com [216.32.180.22] with 32 bytes of data:
Reply from 216.32.180.22: bytes=32 time=222ms TTL=245
Reply from 216.32.180.22: bytes=32 time=221ms TTL=245
Reply from 216.32.180.22: bytes=32 time=220ms TTL=245
Reply from 216.32.180.22: bytes=32 time=220ms TTL=245

Ping statistics for 216.32.180.22:
Packets: Sent = 4, Received = 4, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 220ms, Maximum = 222ms, Average = 220ms

Hi,

I will get back to you on this shortly.

Hi,

Below is the code example to first send the query of type MX to get the mail exchange server and then send A type query to get the IP address.


Dim client As New DnsClient
’ MX query to get the mail exchange address
Dim mxQuestion As Question = New Question(“microsoft.com”, QueryType.MX)
Dim serverList As String() = {“218.102.32.208”, “203.198.23.208”}
client.DnsServers = serverList
If client.Resolve(mxQuestion) Then
For Each record As ResourceRecord In client.ReceivedMessage.Answers
Dim mxRecord As MXResourceRecord = TryCast(record, MXResourceRecord)
If Not mxRecord Is Nothing Then
Console.WriteLine("Exchange Name: " & mxRecord.ExchangeName)
’ A query to get the ip address
Dim aQuestion As Question = New Question(mxRecord.ExchangeName, QueryType.A)
If client.Resolve(aQuestion) Then
For Each innerrecord As ResourceRecord In client.ReceivedMessage.Answers
Dim arecord As AResourceRecord = TryCast(innerrecord, AResourceRecord)
If Not arecord Is Nothing Then
Console.WriteLine("IP Address: " & arecord.Address.ToString())
End If
Next
End If
End If
Next
End If