-->
Page 1 of 1

ESP as SLIP interface and router

PostPosted: Mon Jan 30, 2017 9:45 am
by martin_g
With this firmware the ESP8266 implememnts a SLIP (Serial Line IP) netif-interface and can act as (NAT) router to the internet via the WiFi link: https://github.com/martin-ger/esp_slip_router.

This can be used as simple and cheap network interface e.g. for a Raspberry Pi (zero). It only requires a serial link and it can provide full internet connectivity. Of cause, the bandwith is somewhat limited to the baud rate of the serial line. IoT-protocols are fine, termial access as well, browsing is possible but slow (115200 bps). The router can be configured (once) via a console interface and the config can be stored in flash.

The software is based on a custom-version of the esp-open-lwip lib and a modified UART driver. For debugging purpose also a SoftUART is included.

Re: ESP as SLIP interface and router

PostPosted: Sun May 27, 2018 4:42 am
by martin_g
The SW has been extended to work also as AP - useful e.g. if you want to connect other devices to a RasPi or other LInux box that has no WiFi interface or to have a separate WiFI for IoT only.

With a Linux-based host start the firmware on the esp, connect it via serial to USB, and use the following commands on the host:

Code: Select allsudo slattach -p slip -s 115200 /dev/ttyUSB0&
sudo ifconfig sl0 192.168.240.2 pointopoint 192.168.240.1 up mtu 1500
sudo route add -net 192.168.4.0/24 gw 192.168.240.1


Then

Code: Select alltelnet 192.168.240.1 7777


gives you terminal access to the ESP as router. On the ESP you then enter:

Code: Select allCMD>set ap_ssid <your_ssid>
CMD>set ap_password <your_pw>
CMD>set use_ap 1
CMD>save
CMD>reset


Now STAs of this AP get IP adresses in the 192.168.4.0/24 network and can reach the Linux machine as "192.168.240.2". The AP interface is NATed, i.e. you cannot set up connections from the Linux machine to the STAs, but from STAs to Linux works. Useful e.g. if you want to reach an MQTT server on the Linux.