Skip to content
Discussion options

You must be logged in to vote

Just for anyone who may be interested in enabling NAT on their ESP32

Add this to your modenetwork.c located in /ports/esp32


#include "lwip/lwip_napt.h"

STATIC mp_obj_t esp_nat_enable(size_t n_args,const mp_obj_t *args){
    wlan_if_obj_t *self = MP_OBJ_TO_PTR(args[0]);
        if(self->if_id!=1)
        return;
    tcpip_adapter_ip_info_t info;
    tcpip_adapter_dns_info_t dns_info;
    tcpip_adapter_get_ip_info(self->if_id, &info);
    
    tcpip_adapter_get_dns_info(self->if_id, DNS_MAIN, &dns_info);
    
    u32_t *dns_ip = (u32_t *)&dns_info.ip;;
    
    u32_t *ip = (u32_t *)&info.ip;
    ip_addr_t dnsserver;

    dhcps_offer_t dhcps_dns_value = OFFER_DNS;
    dhcps_set_option_info…

Replies: 3 comments 3 replies

Comment options

You must be logged in to vote
1 reply
@krishnak
Comment options

Comment options

You must be logged in to vote
0 replies
Answer selected by krishnak
Comment options

You must be logged in to vote
2 replies
@krishnak
Comment options

@stephanelsmith
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants