Comments (3)
I have the same issue. Is there a solution for this?
from esp32_nat_router.
Hi,
I also wanted to use@martin-ger great work but with a static IP on the STA.
I think the original code is not working because when a static ip is defined, the DNS is not properly configured.
I had success by changing a piece of code in file: esp32_nat_router.c, function: wifi_event_handler, for the switch/case of: SYSTEM_EVENT_STA_GOT_IP
This piece of original code:
if (esp_netif_get_dns_info(wifiSTA, ESP_NETIF_DNS_MAIN, &dns) == ESP_OK) {
dhcps_dns_setserver((const ip_addr_t *)&dns.ip);
ESP_LOGI(TAG, "DHCP: set dns to:" IPSTR, IP2STR(&dns.ip.u_addr.ip4));
}
I changed it to:
if (has_static_ip) {
// Configure static DNS from DEFAULT DNS
ip_addr_t dnsserver;
dnsserver.u_addr.ip4.addr = ipaddr_addr(DEFAULT_DNS);
dnsserver.type = IPADDR_TYPE_V4;
dhcps_dns_setserver(&dnsserver);
ESP_LOGI(TAG, "STATIC IP: set dns to:" IPSTR, IP2STR(&dnsserver.u_addr.ip4));
}
else {
// Configure DNS from STA DHCP
if (esp_netif_get_dns_info(wifiSTA, ESP_NETIF_DNS_MAIN, &dns) == ESP_OK) {
dhcps_dns_setserver((const ip_addr_t *)&dns.ip);
ESP_LOGI(TAG, "DHCP: set dns to:" IPSTR, IP2STR(&dns.ip.u_addr.ip4));
}
}
In my case, I also updated the DEFAULT_DNS define, as I wanted to use my router ip address.
I am not using any of the portmap features, so I have not tested this change outside of my usage scope.
PS: The "new code" can probably be simplified to make the setserver and ESP_LOG instructions generic, and outside/after the if has_static_ip
from esp32_nat_router.
Here's a patch with the above code. Three sections:
First: Change default DNS to opennic dns server instead of Google
Second: Add (modified) above code to git source
Third: Update web page to hide STA password
from esp32_nat_router.
Related Issues (20)
- Disabling the wifi output
- Configuration with ESPHOME HOT 2
- Very slow speed HOT 6
- Slow HOT 1
- Can't build binaries for ESP32S2
- build error HOT 1
- Portmapping Not Working After First Reboot/Startup HOT 1
- Esp32
- configuration help HOT 1
- esp 32 not syncing . not able to flash the firm ware
- how to clear command history?
- Porting for RTL8720DN
- I can't connect to esp32c3 HOT 5
- Future Requests: add custom mac & hostname
- do not build this project
- No module named kconfgen
- NO XMC flash detected! HOT 1
- No internet connection from nat router HOT 7
- esp32s3 can not fiund router HOT 1
- the kconfigs.in and kconfigs_projbuild.in files could not be found HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from esp32_nat_router.