cancel
Showing results for 
Search instead for 
Did you mean: 

mDNS on LWIP TCP server

jaykay
Associate

I'm tying to setup TCP server using ethernet communications (Nucleo-F767ZI) and find that I can ping the board using the router allocated IP address but I'd like to do the same using Hostname. In STM32CubeMx .ioc file, under Network Interface Options, LWIP_ENABLE_NETIF_HOSTNAME is set to 'enable' and I've set the host name I want to use in LWIP_NETIF_HOSTNAME to 'my_lwip'. However, I still find that I cannot ping the board using the hostname. I know my router DNS is working Ok because I can ping a Raspberry Pi using it's host name.

I realize that in STM32CubeMX generated lwipopts.h #define LWIP_NETIF_HOSTNAME is set to my_lwip by default but I change this to 1 manually. Otherwise, in ethernetif.c, the statement netif ->hostname - "my_lwip" is not enabled.

I think mDNS has to be enabled in LwIP. However, under MDNS/TFTP tab in CubeMX, LWIP_MDNS is always disabled and there is no enable option in the drop-down list.  I've seen a post that suggests to enable LWIP_MDNS, LWIP_UDP and LWIP_IPV4_IGMP have to be enabled.  However, I find that LWIP_IPV4_IGMP has the same issue i.e. no enable option in the drop-down list.   Has anybody successfully enabled mDNS? Thanks.

 

 

4 REPLIES 4
STea
ST Employee

Hello @jaykay ,

In order to make this work here are the steps you should follow:

Make sure to display the help for each LWIP option in CubeMX, using the round "i" button, and note that in some panels there is a "Show advanced parameters" checkbox which may need to be activated in case the required parameter is hidden by default.

To enable mDNS: * Under key options, enable LWIP_MULTICAST_TX_OPTIONS *

Under general settings, enable LWIP_IGMP *

Now in the mDNS/TFTP tab, it should be possible to enable mDNS It may be necessary to also show the advanced options in the mDNS tab and enable LWIP_MDNS_RESPONDER.
note that IGMP flag doesn't get set directly from MX and should be done manually in previous version of MX and it will be fixed in upcoming revisions.
you will find attached the IOC file with proper configuration for mDNS.
Regards 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hi @STea 

 

I'm trying to do the same thing to resolve my my IP via hostname and I could not achieve the same.

I followed the steps you mentioned.

I could ping my device via the IP attained through DHCP but not through hostname. Looks like the default is set as "lwipW . I tried to ping lwip and lwip.local

surendersampath_0-1730466163763.png

I also override the 

surendersampath_1-1730466307681.png

 

Attached my ethernet.ioc in case if you take a look and help me please.

 

 

 

 

Hello @surendersampath ,

you will find attached the project in which MDNS and all configurations needed where done.

if you are trying to test with direct connection from board to pc this should be done.

added mdns_resp_init(); in MX_LWIP_init() 

and 

in while(1) of main.c		
if(dhcp_supplied_address(&gnetif))
		{
			mdns_resp_add_netif(&gnetif, gnetif.hostname, 60);
			validadd = 1;
		}

Regards

 

In order to give better visibility on the answered topics, please click on Accept as Solution on the reply which solved your issue or answered your question.

Hello @STea 

I have tried the solution you sent but still cannot ping using host name.  In my setup, I've connected the PC and NUCLEO-F767ZI to a Netgear 300 router.  I can ping using the allocated IP address (as seen via TeraTerm) but not the hostname.  Perhaps you can share your test setup?

Regards.