Get IP Address from Website

Hello everybody!

First of all, sorry for my english, but i'm from brazil.

I'm working in a project that is a network monitor. The company that i work needs constant internet connection, so I decided to build a network monitor.

What i'm trying to do is to check internet connection by using "ping" on a server like google. Besides that, i want to check if all our services (Email, website and servers) are online.

I am able to connect my arduino uno + ethernet shield to my network, geting a valid IP Address.

So, here is the script I want to build:

1st - Connect the arduino to network with a valid local IP and MAC.
I am able to do this by using "DHCPAddressPrinter" found here. https://www.arduino.cc/en/Tutorial/DhcpAddressPrinter

2nd - Get the IP address of the websites
I want to get the ip address of services like "smtp.mycompany.com", "pop.mycompany.com", "www.mycompany.com".....

3rd - Will ping this addresses by using "Ping" example avaliable in "ICMP Ping Library" here.
http://playground.arduino.cc/Code/ICMPPing

Since the ping function is working only with an IP address, not a hostname, I need a function that I enter the address "www.google.com" and it returns a number (216.58.202.196 for me in Brazil, right now :slight_smile: ). So I think what i need is kinda request for a DNS server to "translate" the website for an IP address.

The servers with "example.mycompany.com" runs on a shared hosting, so there is no fixed IP number

I found that the example "Ethernet" -> "Webclient" makes a HTTP request with "www.google.com", but I could not make it show the IP address of the website.

Of course I don't need the full code for my project, just this part of the "translation" from "www.site.com" for an IP 123.123.123.123 by a DNS server.

Is that possible?

Once I make it work, I will show here the results.
I'm thinking about using an LCD display to show this monitor display.

Thanks for that.

#include <Dns.h>

IPAddress serverIP; // server IP after dns call
DNSClient dnClient;

  dnClient.begin(Ethernet.dnsServerIP());
  
  if(dnClient.getHostByName("smtp.mycompany.com",serverIP) == 1) {
    Serial.print(F("server ip = "));
    Serial.println(serverIP);
  }
  else Serial.print(F("dns lookup failed"));