Oh no! Where's the JavaScript?
Your Web browser does not have JavaScript enabled or does not support JavaScript. Please enable JavaScript on your Web browser to properly view this Web site, or upgrade to a Web browser that does support JavaScript.

network sub-net with second router

K
kll Posted 5 months agoHardware
for some time i am interested to shift my work
into a extra network


there is so many confusing info out there
i watch several videos over the years about to use a second router to setup a sub-net
Ethernet and WiFi
for my
* Raspberry Pi 2/3/4
* PICO W, PICO 2W
* ESP32S3

* PC win 10 as Development station Arduino / Python ( that must work in both networks?)
* slow Laptop Linux KDE PLASMA NEON ( but has Ethernet and WIFI )

but still have internet access through main router
for update, NTP, remote Broker, this BLOG ..

generally my hardware is old, CAT5 cable.. RPIs are slow anyway
best is my PC Ethernet to TOT router ZTE with 4 Ethernet and 1 USB,
with Ookla speed test
Download <1000Mbps
Upload <500Mbps

not bad for a fiber-line subscription,
when prepaid 105 €/a, not get refund but higher speed.

but sadly from Thailand like to Europa or USA internet kind of slow.


this said i am not into high end router, just a separate network for my play.
and i found a old TOT router DB120 not sure it still works
but even a WiFi 7 mesh , 2.4 / 5 GHz router is only 120€
but makes no sense at the end of a slow internet.


while many videos actually NOT make a sub-net
instead a Access Point for ? extended WiFi range ? ( second router IP like 192.168.1.220 )
watching youtube video
point seems to be:

primary router

( first network )
192.168.1.1
DHCP enabled
( change to fix band 6 )


secondary router

( sub-net )
192.168.2.1
255.255.255.0
gateway 192.168.1.1

disable UPnP and DHCP Server
( change to fix band 11 )
use same SSID and PASSWORD ??? for what ?
WPA2-PSK
then connect
Ethernet LAN to LAN cable



at first the idea is to use this old router as second network master
* need to power up
* connect by Ethernet to laptop / while its WiFi is off /
* use hardware or software RESET first ( 10 sec press reset with a pin ( small hole on 2nd router ))
* check IP you got on Ethernet port from that router
[windows key][r] cmd
ipconfig
see: 192.168.1.5 as own IP

* try to login browser 192.168.1.1 ( initial ip of second router )
( admin tot )
change router IP to 192.168.2.1
( save and reboot router )
and actually needed to reboot laptop too to get a new IP in the new sub-net

new SSID new PASSWORD for the secondary router WiFi (sub-net)
( ok here i fail, as the old box has no WiFi )




but i was in a hurry to test something
so i try following:

SAMSUNG_TAB_HOTSPOT


my tablet has data SIM
and first i switch OFF wifi ( to my home router )
then enable HOTSPOT
wifi is on again in AP mode
it provides
* SSID
* password
but not its IP range
so first login with the laptop ( and test internet connection )
then i burn a PICO 2W (and a ESP32S3 later )
but login did not work, so i disabled my fixIP thing i setup there
now it
* login HOTSPOT
* connect NTP to get the time
* start a webserver
* login remote MQTT HIVEMQ TLS and send data ( now also a BootLog text in 4 chunks a 200 chars in TOPIC: /xxx/Dyyy/log )





BUT
sure in our project need a extra equipment?
well if you plan a
* RPI4 server Mosquitto / Node-Red /
(Ethernet connected )
* one or more PICO 2W or ESP32S3 serving web-page and mqtt data
( WiFi connected )

and want install it at a customers network you need adjust lots of details...
so with own sub-net router your project could be complete besides the
LAN Ethernet cable to customers Internet router.



OR
could try to let the RPI do that job too?

RPI HOTSPOT


its connected Ethernet to the main router as 192.168.1.104
and the WiFi is unused / disabled / wifi country not set

can make that a HOTSPOT?
for the small WiFi devices?
would they be able to reach internet ( for NTP ) or serve web-page to main router users?


here i check on 2 example
https://raspberrytips.com/access-point-setup-raspberry-pi/
https://learn.sparkfun.com/tutorials/setting-up-a-raspberry-pi-3-as-an-access-point/all

https://www.raspberrypi.com/tutorials/host-a-hotel-wifi-hotspot/


that i try on my backup drive RPI4
a powerful WD-Black 240GB M2-SSD in a ORICO USB3 adapter
( and it has a RED cooler grill )
with RASPBIAN 64bit desktop installed

-1- update / restart

-2- on desktop or by terminal
sudo raspi-config / Localisation Options / WLAN country
i select TH, ok, exit,

-3-
enable HOTSPOT
sudo nmcli con add con-name hotspot ifname wlan0 type wifi ssid "RPI-HOTSPOT"
sudo nmcli con modify hotspot wifi-sec.key-mgmt wpa-psk
sudo nmcli con modify hotspot wifi-sec.psk "raspberry"
sudo nmcli con modify hotspot 802-11-wireless.mode ap 802-11-wireless.band bg ipv4.method shared

sudo nmcli -o c

sudo nmtui






in phone i find
network router 10.42.0.1
NO INTERNET ACCESS ????

//
sudo nano /etc/sysctl.conf
enable aka delete #
net.ipv4.ip_forward=1

was not installed:

sudo apt install iptables


sudo iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
sudo iptables -A FORWARD -i eth0 -o wlan0 -m state --state RELATED,ESTABLISHED -j ACCEPT
sudo iptables -A FORWARD -i wlan0 -o eth0 -j ACCEPT

sudo sh -c "iptables-save > /etc/iptables.ipv4.nat"


to enable that on reboot need:
sudo nano /etc/rc.local
did not exist here so create and add
iptables-restore < /etc/iptables.ipv4.nat
exit 0

and
sudo reboot

try again login RPI-HOTSPOT raspberry
and got a internet site in browser, so it seems to work ( while i still see "no internet access" )



now try in my ESP32S3
secrets.h
use:

#define SECRET_SSID "RPI-HOTSPOT"
#define SECRET_PASSWORD "raspberry"

but failed to connect ????

i try again but set ( enable ) in web-wifi.ino

WiFi.setMinSecurity(WIFI_AUTH_WEP); // should help on certain router problems

and got connection

www ESP32 board MAC Address: C0:4E:30:3A:16:54
www Connected to RPI-HOTSPOT
www IP address: 10.42.0.37
...www Setup ntp...
www Waiting for NTP time sync / max 30 sec 
www Current time: GMT Fri Mar 21 09:03:34 2025

www Local time: 2025-03-21 16:03:34
uptime [s]: 7.62
www HTTP server started on http://10.42.0.37:1234
uptime [s]: 7.62
mqtt setup_MQTT
mqtt try connect to MQTT broker ...
mqtt broker: 192.168.1.104 connected
mqtt publish to topic: 
ESP32S3/D216/status
ESP32S3/D216/log
ESP32S3/D216/data
mqtt subscribe to: 
ESP32S3/D216/set
ESP32S3/D216/fdata
END SETUP
uptime [s]: 7.70
mqtt send BootLog len : 769
...........................
{ "id": 0, "dev":"ESP32S3/D216/data", "datetimes": "2025-03-21 16:04:00", "PS_Temp": 37.2, "A0V": 0.729, "A1V": 0.699, "A2V": 0.098, "DOUTS": "0, 0, 0, 0,", "VDC": 12.680, "ADC": -0.007, "POW": -0.007 }
...


so WiFi login, NTP, Mosquitto MQTT
OK
BUT
from phone login RPI-HOTSPOT
browser
http://10.42.0.37:1234

is unreachable