

You can then read the ARP table to obtain the MAC address of the gateway (router). The router will reply to your ARP request with its MAC address.ģ. You can do this using the etharp_request function.Ģ.

Send an ARP request to the broadcast address asking for the MAC address of the router. To obtain the MAC address of the router (gateway) using eth connection, you can try the following steps:ġ. I thought that MAC router appears in the ARP table after the DHCP process LE: it's working ! I have entrys in ARP table.īut is need to I ping esp32 from network. To get the MAC address of a router using the `etharp_get_entry` function on an ESP32 with Arduino, you can start by including the following libraries at the beginning of your sketch: Please note that I'm not an Arduino Profi, and I'm not sooooo familiar with the specifics of the Arduino IDE or your network setup, so I can only provide general advice and not an exapmple - but hopes this helps for the basic to get on. You may need to provide additional information such as the index_entry, ip, and netif parameters to properly retrieve entries in the table. If the ARP table is empty, it might be because there are no entries in the table yet or because the function is not being called correctly. To read the ARP table, you can use the etharp_get_entry() function as you mentioned. Once you receive the ARP response, it will contain the MAC address of the router.

To get the router MAC address, you can send an ARP request to the router IP address and then wait for the router to respond. If the ARP entry is not found, it logs a warning message to the console.Įtharp_get_entry(index_entry, &ip, &netif, ðaddr)ĪRP table is empty, but ethernet is working. If the ARP entry is found, it logs the MAC address to the console.

This code initializes the network interface using Ethernet, gets the IP address information and the ARP cache from the network interface, and finds the ARP entry with the gateway IP address to get the MAC address. * Find the ARP entry with the gateway IP */Īrp_entry_t *arp_entry = arp_table_find(arp_table, &ip_info.gw) ĮSP_LOGI(TAG, "Gateway MAC address: %02x:%02x:%02x:%02x:%02x:%02x",Īrp_entry->mac, arp_entry->mac, arp_entry->mac,Īrp_entry->mac, arp_entry->mac, arp_entry->mac) ĮSP_LOGW(TAG, "ARP entry not found for gateway IP") Įsp_netif_config_t netif_cfg = ESP_NETIF_DEFAULT_ETH() ĮSP_ERROR_CHECK(esp_eth_driver_install(Ð_DRIVER_CONFIG, ð_handle)) ĮSP_ERROR_CHECK(esp_eth_start(eth_handle)) ĮSP_ERROR_CHECK(esp_netif_set_default(eth_netif)) * Function to get the default gateway MAC address */Įsp_netif_get_ip_info(eth_netif, &ip_info) Īrp_table_t *arp_table = esp_netif_get_arp_cache(eth_netif)
