why 192.168.4.1

I noticed that when no router is available several projects use 192.168.4.1 as the default IP address. The device offers a a web server to allow configuration.
Why isnt the device using Automatic Private IP Addressing which would get a 169.254.x.x address?

The code is in the libraries. This range also seems a good place for sensors that should never be accessed from the internet. This range is not forwarded by routers.

Is there a good reason to have sensors accessible when you could pass just the data via say a MQTT broker?

Which Arduino board is used in those projects ?
Can you give a link to the libraries where that code is ?

169.254.x.x is NOT VALID IP address!
This is automatic IP address that is set to device, if DHCP cant set its address.
It's FAULTY indicator IP adress, you cant connect to that device! It is not in your "network".

About what boards are u talking?
If about ESP related, IP adress 192.168.4.1 in AP mode is used, because it is first IP adress in C type network that is using 24-bit mask. Standard LAN network have 192.168.1.0 or 192.168.0.0 network, so if you connect ESP with STA + AP mode to your home WiFi network ,there can be problem, because if you use 192.168.1.1 there if will override with IP address of your router! So 192.168.4.0 network is less used, so it is used as standard in many ESP related example code with ESP as AP (Access Point).

It is a valid address range. There are RFCs for "local link addresses". It may seem invalid because it means the device could not find a DHCP server and that is usually not good.

These addresses are not routable so the device can't get on the internet but that is why I ask. Wouldn't it be safer to have sensors kept away from the internet? Same for devices that are sitting in configure me mode.

192.168.X.X is easier to remember than 169.254.X.X, and people are more
familiar with the 192.168.X.X address.
Notice how martinius96 reacted and outright said the 169.254.X.X is invalid?

Both are valid and useable in a local area network

:slight_smile: OK
So, enjoy new 169.X.X.X address each few mins.
It will work.

This topic was automatically closed 120 days after the last reply. New replies are no longer allowed.