WIFI STA with Static IP but variable Router Gateway Address

rodmcm
Posts: 70
Joined: Sat Sep 02, 2017 3:31 am

WIFI STA with Static IP but variable Router Gateway Address

Postby rodmcm » Mon Jan 19, 2026 3:48 am

To set a static IP on an ESP32 you need to include the gateway address. The most common default is 192.168.1.1
But others are possible depending on the manufacturer of the router.
Does anyone have a technique to set a static IP without knowing the gateway address, or a method to first find the Gateway address

lbernstone
Posts: 1131
Joined: Mon Jul 22, 2019 3:20 pm

Re: WIFI STA with Static IP but variable Router Gateway Address

Postby lbernstone » Mon Jan 19, 2026 5:34 pm

No. This is the whole purpose of DHCP. When you first connect, it sends a broadcast out onto the local network. The DHCP server directly responds to provide the device with the information it needs to operate in the TCP/IP stack (a free address, gateway, netmask, DNS, etc).
There are brute force hacking methods to try to discover the gateway, but you will have to look on the dark net if you want to be a script kiddie.

rodmcm
Posts: 70
Joined: Sat Sep 02, 2017 3:31 am

Re: WIFI STA with Static IP but variable Router Gateway Address

Postby rodmcm » Tue Jan 20, 2026 10:48 pm

Thanks for that... Can you point me to a code example...

rodmcm
Posts: 70
Joined: Sat Sep 02, 2017 3:31 am

Re: WIFI STA with Static IP but variable Router Gateway Address

Postby rodmcm » Tue Jan 20, 2026 11:52 pm

The reason I ask is that every piece of code I have found requires the Gateway address as part of WifI.config() (Arduino) to be able to set a static IP.

Who is online

Users browsing this forum: Google [Bot] and 9 guests