Sending UDP to global DNS

取消
显示结果 
显示  仅  | 搜索替代 
您的意思是: 
已解决

Sending UDP to global DNS

跳至解决方案
618 次查看
skteh
Contributor III

Hi,

I have a problem to send an UDP packet to global DNS like Google DNS 8.8.8.8. I always get host unresolved error. When I try to send to local ip(my pc 192.168.10.76, my controller 192.168.10.10), I got no problem.

Can anyone please advice?

Thank you.

0 项奖励
1 解答
453 次查看
skteh
Contributor III

Hi David,

Thank for fast respond.

I just found my problem, I didn't enable gateway.

Now, I'm able to send UDP to internet already.

Thank you,

在原帖中查看解决方案

0 项奖励
3 回复数
453 次查看
frandelgado
Contributor I

I have a problem with dns, dns did not work. I have the k60 module with MQX 3.7 operating system. The dns's introduce this:

while (DNS_init ()! = RTCS_OK)

{

_time_delay (1000);

}

strcpy (string, "google.com.");

host = gethostbyname (string);

while (host == NULL)

{

if (host! = NULL) {

name = host-> h_name;

alias1 = host-> h_aliases [0];

name2 = host-> h_aliases [1];

type = host-> h_addrtype;

length = host-> h_length;

ipDNS = * (uint_32_ptr) host-> h_addr_list [0];

}

host = gethostbyname (string);

}

When initializing the ethernet I have to call the function ipcg_add_dns?

  ipcfg_init_device (DEMOCFG_DEFAULT_DEVICE, address);

_ip_address DNS_server_ipaddr;

    DNS_server_ipaddr = inet_addr ("8.8.8.8");

    if (ipcfg_add_dns_ip (DEMOCFG_DEFAULT_DEVICE, DNS_server_ipaddr) == TRUE)

     {

     printf ("DNS added ok");

     } else {

     printf ("DNS added NOT ok");

     }

In addition to the file dnshosts.c must configure something?

thank you

0 项奖励
453 次查看
DavidS
NXP Employee
NXP Employee

Hi SK,

It has been about a year since I did experiment with DNS.

I implemented it into the web_hvac demo project and tested with twr-k60d100m.

The files I enhanced to use the shell command line to test DNS are attached.

Note I was using MQX4.0.2.

Regards,

David

454 次查看
skteh
Contributor III

Hi David,

Thank for fast respond.

I just found my problem, I didn't enable gateway.

Now, I'm able to send UDP to internet already.

Thank you,

0 项奖励