mongoose-os icon indicating copy to clipboard operation
mongoose-os copied to clipboard

Nameserver handling

Open DrBomb opened this issue 6 years ago • 0 comments

Platform: ESP32 with multiple network interfaces. Wifi, Eth and PPPoS together.

MongooseOS handles nameservers on an odd way.

The NET event handler installed by mgos_net.c takes care of setting the system's nameserver on Line 103, while said nameserver is fetched from the function mgos_get_nameserver on the same file.

The problem is, the mgos_get_nameserver function defaults to getting the nameserver from the wifi.sta.nameserver entry (ignoring sta index), and if the string is empty it tries to get it from here (I don't know if other platforms have their own implementation), and ONLY IF the device has WIFI, because it is enclosed on an #ifdef block, otherwise returning NULL.

This brings a few issues:

  • mOS will not get a nameserver set if the Wifi lib is not built with the firmware.
  • The multiple sta settings are ignored. Thing that does not really matter but it should be at least noted
  • wifi.sta.nameserver defines the global nameserver. Even on other interfaces like PPPoS and Ethernet. It works for me, but it should be on a different location.
  • Nameserver settings are set multiple times on every MGOS_NET_EV_IP_ACQUIRED event. I believe the first interface connected dictates the nameserver for the rest of the system. Meaning that if you have a local ETH interface with no internet and a PPPoS interface that does, even after setting the default interface in LWiP, the name resolution will be what the ETH sets, which is usually the default gateway which fails.

I would suggest moving the nameserver config entry to a different path, like device.nameserver

DrBomb avatar Nov 12 '19 20:11 DrBomb