How to get ip information of arouter/AP with ESP8266
All you can do is get what DHCP gives you.


Connect to the AP
Use DHCP to get an IP address
Store the IP, netmask and gateway in variables
Use the netmask to determine the "fixed" bits in the IP address.
Replace the "unfixed" bits of the IP with your own chosen IP portion
Re-set the IP information with your static information.


What you cannot do is determine what the DHCP range is. Only the router knows that, and it doesn't broadcast it.

The proper way of handling it, though, is to get the router to provide a fixed DHCP IP address for the MAC address the ESP8266 has. Most routers have this functionality available.