Disable MBed OS DNS altogether


I am using MBed OS in a very controlled environment, where every device has its own static IP address. Furthermore there are rather tight restrictions on the application size, so I am looking into reducing the size of the final binary as much as possible.

When looking at the map file I noticed that the DNS part of the ethernet stack does use quite a lot of room. I don’t need DNS, as outlined above, so I had a look into disabling it. As far as I can tell there is no way of doing it other than editing the LWIP options and part of the LWIPInterface class.

Question: Is there a easier way of disabling DNS in the LWIP stack or MBed OS in general? Was this use-case considered at any point?

Further Info: I am currently using Mbed Os 6.2 with the corresponding mbed-cli tools. The development boards I use are the NUCLEO-L552ZE-Q with an external EMAC and the NUCLEO-H743ZI, although other NUCLEO boards are available and could be tested.

Any advice or thoughts are appreciated :slight_smile:


Hi @cjost ,

I’m afraid disabling DNS operations is not implemented at the moment. If you want to disable it in the LWIP stack, you have to fiddle with liwoptsh and turn it off: #define LWIP_DNS 0 (line 195). As you noted part of the LWIPInterface class have to be modified. To reclaim the most byte out of that change I would also suggest providing conditional guard to the mbed::DNS class. Some changes have to be propagated up to the socket, for example, sendto use gethostbyname.

If you intend to modify your source tree to accommodate such scenario I would suggest opening a pull request in mbed-os repository. We can help you there with the change and it would be committed durably into Mbed OS.

Hi Vincent,

thanks for your input. Currently I am looking for other places where I can restrict the app size. This is mostly due to the many changes you already hinted at.

However I guess at some point I will try to implement this. Thank you for showing the way on how to do this.