DNS issue with mbed-http

Hi,

I have a weird issue on Ethernet interface.
Indeed, I connect my Nucleo-F767ZI board through an ethernet connection in DHCP.
It works almost well, indeed the ip address, gateway, netmask are ok but the DNS server is NULL.
If I connect my laptop to the same network cable then the DNS is set with the same IP as the gateway.
So, why the DNS is empty in DHCP mode ?

Here is my code:

_ethernetInterface.set_dhcp(true);

_ethernetInterface.connect();   

nsapi_connection_status status = _ethernetInterface.get_connection_status();

printf("Status = %d\r\n", status);

SocketAddress address;

_ethernetInterface.get_ip_address(&address);

printf("IP : %s\r\n", address.get_ip_address() ? address.get_ip_address() : "None");

SocketAddress netmask;

_ethernetInterface.get_netmask(&netmask);

SocketAddress addressGateway;

_ethernetInterface.get_gateway(&addressGateway);

printf("IP Gateway : %s\r\n", addressGateway.get_ip_address() ? addressGateway.get_ip_address() : "None");

SocketAddress addressDns;

_ethernetInterface.get_dns_server(0, &addressDns);

printf("IP DNS = %s\r\n", addressDns.get_ip_address() ? addressDns.get_ip_address() : "None");

Thanks
Frédéric

1 Like

I have the same problem as you with F767ZI. I tried to add dns server with add_dns_server and fails too. Any tips to debug it would be appreciated. Regards

Hi,

Well I didn’t find a way to make it works. So I decided to detect the ethernet connection state ( using interruption attach ) and then to retrieve the gateway ip address and assign it to the gateway…

ethernetInterface->set_blocking(false);
ethernetInterface->attach(&EthernetConnectionCallback);
ethernetInterface->set_dhcp(true);    

…

SocketAddress addressGateway;
result = ethernetInterface->get_gateway(&addressGateway);
result = ethernetInterface->add_dns_server(addressGateway, NULL);

If you find another way to make it works, I will be very pleased !

Kind regards,
Frédéric