Sample sketch fails

I now have a sketch that creates an AP at the IP of my choice (192.168.5.1) or if I don't specify one, it defaults to 192.168.4.1. I can also create a Station with either a static IP or provided by DHCP.
Keeping in mind the purpose of the sketch was to determine why the sample sketch seen in post 1 where the comments say to use 192.168.4.1 as that is the default did not work. The reason was because I did not know that I had to connect my PC/phone to the AP. I also did not know my PC or phone I could be connected to two networks at the same time. I don't know why I didn't know that as I have several devices that work by connecting my phone to a 'special' AP then the device can be controlled either by an app or a web page.
I am sure many folks tried to tell me that but I just did not understand mostly due to too many new words i one sentence/paragraph.

Example:
Your last post and a few before still confuse me. When my modem/router is on 192.168.4.1 and my esp32 is on 192.168.5.1 I connect by adding the AP on the esp32 by selecting it from the wifi app list of AP's around me (several hundred folks all with an AP)

Are you telling me I can 'hard code' the 192.168.5.1 in my WiFi 'config' on my Mac somewhere?

NEWS FLASH
I just experienced an outage of the internet while writing this and now understand that both the ISP MODEM/ROUTER and the ESP32 AP (same as a router sort of?) are NOT connected at the same time because they both have the same IP although I also saw a new IP of 192.168.4.2. Was that the 'client' connection?
I will now try creating the esp32 AP at 192.168.5.1. Same result, no internet but I have 192.168.5.1 and 5.2 (client?)
WHere exactly do I add the 192.168.5.1? This will allow my Mac to access the internet AND my esp32 AP, correct?

How/where do I do this? I asked Claude, but it said I needed a second NIC, which I am not willing to do.
Instead, I changed to STA mode, and I can now communicate with both the ESP32 and the internet.

I don't have ever had a Mac (and I won't, sorry, I hate Apple...) but Gemini says:

On a MacBook, adding a second IP address to the same network card (known as IP Aliasing) isn't as straightforward as it is on Windows because the standard interface hides these advanced options.

Here are the two best ways to do it.


Method 1: The Terminal (Recommended)

This method is instantaneous and doesn't require restarting your Wi-Fi service.

  1. Open Terminal (found in Applications > Utilities or via Spotlight).
  2. First, identify your Wi-Fi interface name (usually en0). Type: networksetup -listallhardwareports
  3. Once you confirm Wi-Fi is on en0, use the ifconfig command to add the alias:Bashsudo ifconfig en0 alias 192.168.5.100 255.255.255.0
  4. Enter your system password when prompted.

Note: This command is temporary. If you restart your Mac or toggle the Wi-Fi off and on, the secondary address will disappear.


Method 2: System Settings (Service Duplication)

If you want a permanent solution that stays active even after a reboot, you need to "trick" macOS by creating a virtual service.

  1. Go to System Settings > Network.
  2. Click on the Wi-Fi service.
  3. At the bottom of the list, click the three-dot icon (or the down arrow) and select "Duplicate Service...".
  4. Give the new service a name (e.g., "Secondary Wi-Fi").
  5. Select this new service, click Details... > TCP/IP.
  6. Set "Configure IPv4" to Manually and enter your IP 192.168.5.100 along with the subnet mask.
  7. Click OK and then Apply.

How to verify it's working

To make sure your MacBook is actually "listening" on both addresses, go back to the Terminal and type:

ifconfig en0

You should see multiple lines starting with inet. One will show your .4.100 and the other your .5.100. If you can "ping" a device on the .5.x network, you're all set!

TL;DR
I solved that problem by using a STA.