ESP8266 lwip IP_FORWARD/routing

ajay.bhargav
Posts: 11
Joined: Fri Jul 17, 2015 7:13 pm

ESP8266 lwip IP_FORWARD/routing

Postby ajay.bhargav » Tue Aug 18, 2015 5:39 am

Recently Espressif has released lwip source for SDK 1.3.0 Thank you so much for this...
Now my setup is like this:
pc<->router<->(sta)esp(ap)<->esp2(sta)
I want to ping esp2 from my pc. I enabled IP_FORWARD in lwipopts.h and rebuild sdk. esp2 connects to esp (also connected to router). But I am not able to ping esp2 from PC. So my question is it possible for esp8266 to forward ip packets between station and AP interfaces? Has anyone tried it? It will be a really helpful thing to implement if we want to use esp as a gateway to internet or something similar.

Please let me know if anyone else is trying something similar.

Regards,
Ricky

eriksl
Posts: 157
Joined: Fri May 22, 2015 6:22 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby eriksl » Tue Aug 18, 2015 4:09 pm

There appears to be an LWIP option (compile-time) to enable routing. I have no idea how "smart" the routing is and also, the added code won't be an immediate problem, but it may flood your dram or iram usage, and they're quite small.

ajay.bhargav
Posts: 11
Joined: Fri Jul 17, 2015 7:13 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby ajay.bhargav » Tue Aug 18, 2015 6:27 pm

I am using this source template:
Open source LWIP for esp_iot_sdk_v1.3.0

and enabled IP_FORWARD which as per lwip suppose to make stack to route packet between networks.

Code: Select all

/**                                                                             
 * IP_FORWARD==1: Enables the ability to forward IP packets across network       
 * interfaces. If you are going to run lwIP on a device with only one network   
 * interface, define this to 0.                                                 
 */


I am assuming we are having two different interfaces STATION_IF and SOFTAP_IF. I am not sure if thats true... It would be really great if espressif can have a simple routing feature. Has anyone else tried doing this?

eriksl
Posts: 157
Joined: Fri May 22, 2015 6:22 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby eriksl » Tue Aug 18, 2015 7:43 pm

I don't understand what you're trying to do with routing. For routing you need two LAYER 3 interfaces. The esp8266 has only one. Out of the box it can't use multiple SSIDs nor VLAN tags, so???

Aren't you confusing routing with bridging? An access point usually can be configured to enable or disable it ("client isolation").

ajay.bhargav
Posts: 11
Joined: Fri Jul 17, 2015 7:13 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby ajay.bhargav » Wed Aug 19, 2015 12:24 am

eriksl wrote:I don't understand what you're trying to do with routing. For routing you need two LAYER 3 interfaces. The esp8266 has only one. Out of the box it can't use multiple SSIDs nor VLAN tags, so???

Aren't you confusing routing with bridging? An access point usually can be configured to enable or disable it ("client isolation").

You're right I am confused. I actually do not want routing it is a wrong word to use here.
PC (192.168.0.2) <-> (192.168.0.3) ESP1 in STA+AP (192.168.4.1) <> (192.168.4.2)ESP2
So basically I just my pc to see device (ESP2) on the other end of ESP1. I should be able to ping 192.168.4.2 from 192.168.0.2 .. something...
So I should say NAT or Bridge? NAT seems more appropriate here? I have a doubts can SOFTAP and STATION be considered as two wifi interfaces?

Sorry for asking too many questions... :roll:

eriksl
Posts: 157
Joined: Fri May 22, 2015 6:22 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby eriksl » Wed Aug 19, 2015 6:12 pm

NAT is also a layer 3 function.

What you're looking for is really client isolation (or correctly: disabling it).

Espressif will have to make that available.

tve
Posts: 123
Joined: Sun Feb 15, 2015 4:33 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby tve » Thu Aug 20, 2015 1:05 am

I'm not sure what the OP is looking for. If you're looking to:
- route packets between a STA connected to the ESP's SOFT-AP and the internet (or some other box) connected via the ESP's STA and your standard AP then you're looking for routing and the ESP does have two interfaces with separate IPs for the two functions (SOFT-AP and STA)
- route packets between multiple STAs connected to the ESP's SOFT-AP then you're looking neither for routing nor bridging but layer-2 forwarding of packets at the SOFT-AP level

ajay.bhargav
Posts: 11
Joined: Fri Jul 17, 2015 7:13 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby ajay.bhargav » Thu Aug 20, 2015 3:16 pm

well looks like its not possible :) maybe I will have to implement something to transfer packets between station and softap. I still wonder what IP_FORWARD of lwip does :?

eriksl
Posts: 157
Joined: Fri May 22, 2015 6:22 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby eriksl » Thu Aug 20, 2015 3:48 pm

The forwarding option for LWIP probably just works - if you have two layer 3 interfaces. LWIP isn't used only on esp8266!

neocat
Posts: 1
Joined: Wed Oct 12, 2016 9:27 pm

Re: ESP8266 lwip IP_FORWARD/routing

Postby neocat » Wed Oct 12, 2016 9:33 pm

I have implemented NAT (NAPT) feature to extend Wi-Fi network easily by extending IP_FORWARD in lwip.

Network outline:
Image

The patch:
https://github.com/NeoCat/esp8266-Ardui ... d3f178bcbe

Who is online

Users browsing this forum: No registered users and 9 guests