SDK Lwip DNS - dns_gethostbyname(), how to let it work with static IP settings

キャンセル
次の結果を表示 
表示  限定  | 次の代わりに検索 
もしかして: 

SDK Lwip DNS - dns_gethostbyname(), how to let it work with static IP settings

4,943件の閲覧回数
ping1
Contributor V

Hi, all

Try to use the function to resolve IP address from domain names, it works fine when IP setting is configured as DHCP, however when it is configured as STATIC, it doesn't work. It seems use DHCP server as DNS server.

I run lwip on bare metal - not sure there is any alternative function.

Any suggestion?

Thanks!

Ping

ラベル(1)
0 件の賞賛
返信
3 返答(返信)

4,925件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi @ping1 :

 

Under the DHCP mode, the DNS server is configured correctly by the DHCP server.

With static mode, you need to set the right DNS server by yourself. You should be very careful. Maybe that is the reason.

void  dns_setserver (u8_t numdns, const ip_addr_t *dnsserver)

 

 

Regards

Daniel

0 件の賞賛
返信

4,914件の閲覧回数
ping1
Contributor V

Hi, Daniel

Thanks for reply, you are right that DNS server is handled by DHCP server in DHCP mode.

I just wonder how to get it work in static situation, if it needs DNS server IP address , is there a way to tell the LWIP? will it still work? Any examples?

Thanks

Ping

 

0 件の賞賛
返信

4,910件の閲覧回数
danielchen
NXP TechSupport
NXP TechSupport

Hi @ping1 :

First you need to know the right DNS server in your network, for example, 1.1.1.1

Please refer to below code.

#include "lwip/dns.h"

ip_addr_t dnsServerIp;
IP_ADDR4( &dnsServerIp, "1.1.1.1");
dns_setserver(0, &dnsServerIp);

 

 Regards

Daniel

0 件の賞賛
返信