I have a weird issue. I have an ESP32 embedded device running an mDNS server which I assign a hostname to. For the record, i've included this code for the ESP32 device below.
When I ping this hostname from my Ubuntu PC on the same local network,this hostname becomes local and it is not actually pinging the device. No matter what I change the hostname to on the esp device, this happens. In this case i've named it audio-server and I ping it as follows :
ping audio-server.local PING audio-server.local (127.0.0.1) 56(84) bytes of data. 64 bytes from localhost (127.0.0.1): icmp_seq=1 ttl=64 time=0.026 ms 64 bytes from localhost (127.0.0.1): icmp_seq=2 ttl=64 time=0.048 ms 64 bytes from localhost (127.0.0.1): icmp_seq=3 ttl=64 time=0.048 ms 64 bytes from localhost (127.0.0.1): icmp_seq=4 ttl=64 time=0.044 ms What exactly is going on here?
static void mdns_delegate_hostname(void) { esp_err_t err = ESP_OK; char *delegated_hostname = "audio-server"; esp_netif_t *intf = esp_netif_get_default_netif();; while (intf == NULL) { ESP_LOGE(TAG, "ERROR ! netif is NULL"); intf = esp_netif_get_default_netif(); sleep(2); } mdns_ip_addr_t addr4, addr6; addr4.addr.type = ESP_IPADDR_TYPE_V4; esp_netif_ip_info_t info; esp_netif_get_ip_info(intf, &info); ESP_LOGI(TAG, "IP Address of device is : " IPSTR "\n", IP2STR(&info.ip)); addr4.addr.u_addr.ip4 = info.ip; addr6.addr.type = ESP_IPADDR_TYPE_V6; esp_netif_get_ip6_linklocal(intf, &addr6.addr.u_addr.ip6); addr4.next = &addr6; addr6.next = NULL; ESP_LOGI(TAG, "Setting delegated hostname to %s\n", delegated_hostname); err = mdns_delegate_hostname_add(delegated_hostname, &addr4); if (err != ESP_OK) { ESP_LOGE(TAG, "ERROR Setting delegated hostname to %s\n", delegated_hostname); return; } err = mdns_service_add_for_host(NULL, "_http", "_tcp", delegated_hostname, 80, NULL, 0); if (err != ESP_OK) { ESP_LOGE(TAG, "ERROR adding service for host %s\n", delegated_hostname); } }