rubfi / esphole

Ad blocker for ESP
94 stars 16 forks source link

Alternative DNS Server? #5

Open rotkohlsuppe opened 1 year ago

rotkohlsuppe commented 1 year ago

I wonder how the ESPhole gets the IP addresses for the non-blocked DNS. I assume it's been resolved by the DNS IP from the DHCP Server. I want to setup the ESPHole for a whole little side network. That's why I want to leave the clients (mobile, computer, etc) DNS settings untouched, but alter the DNS settings in my DHCP server, pointing to the ESPHole. But then the ESPHole needs it's own DNS fallback IP, not the one from the router. Otherwise it would create an infinite loop. Is it possible to assign a primary DNS IP address on the ESPHole other than that from the router? Thanks a lot!

TheTechTiger commented 2 months ago

You are correct, the ESPHole uses the WiFi's DHCP Server's DNS to get the ip of non blocked domains, so setting up ur ESP8266's IP as a DNS resolver wouldn't be a great idea. I'm trying to develop a similar version of this project, but instead of using the inbuilt DNSServer library I'm building my own using WiFi UDP. To fix this problem what I've done is something similar to this:

If(<no match in pre defined DNS Records>){
AddCacheEntery(); //this updates a cache list with the DNS transaction ID, IP and port of the sender
Udp.beginPacket(IPAddress(8,8,8,8), 53);//use any DNS Server like 1.1.1.1 or 8.8.4.4 etc
Udp.write(recivedDNSbuffer, packetSize);
Udp.endPacket();
}

Now this just send/forwards the DNS Request to the server and in the loop method u initially check if the packet is from the DNS server, if so then find its transaction ID in the list and and forward the recived packet from the DNS Server to the respective client IP and port and remove this entry as it's resolved Additionally u can also set a timeout in this list for like 3-4s, if there's no response from the DNS server for this transaction ID, send "server Busy" response code delete the entry from the list(I do recommend adding this as node mcu has a tiny 4kb RAM size)