Script to connect to Apartment wifi AP

I’m trying to create a script to connect my Hap AX3 to my apartment AP that is providing a wireless network for my unit. The reason I’m doing this is I originally had it connect to the ethernet port in my room which also created a network for my devices,servers and home-lab. At the moment, while I wait for the network to be diagnosed and fixed I’m actively looking for ways to get my stuff back connected to the internet. Without having it accessible to the whole apartment network.

At the moment I had a script created to do the process then see if I can ping google and other devices. At the moment it is based on the default configuration from MikroTIk. When I try to run this using the “import” command a get the following error. I have inquired to help of GPT but the error persist. [The line and column may be different as I’ve gone through numerous iterations]
Screenshot 2025-01-07 233926.png

Variables

:global apartmentWifi5GHzSSID “Astoria”
:global apartmentWifi24GHzSSID “Astoria_legacy”
:global apartmentWifiPassword “[Redacted]”

Clear existing configuration

/system reset-configuration no-defaults=yes skip-backup=yes

Set up the 5GHz WiFi (WiFi1)

/interface wifi set [find default-name=wifi1] mode=station ssid=$apartmentWifi5GHzSSID security.authentication-types=wpa2-psk security.passphrase=$apartmentWifiPassword disabled=no

Set up the 2.4GHz WiFi (WiFi2)

/interface wifi set [find default-name=wifi2] mode=station ssid=$apartmentWifi24GHzSSID security.authentication-types=wpa2-psk security.passphrase=$apartmentWifiPassword disabled=no

Create a bridge and add WiFi interfaces

/interface bridge add name=bridge-lan
/interface bridge port add bridge=bridge-lan interface=wifi1
/interface bridge port add bridge=bridge-lan interface=wifi2

Assign IP address to the bridge

/ip dhcp-client add interface=bridge-lan disabled=no comment=“Obtain IP from apartment Wi-Fi DHCP”

Enable DNS for local resolution

/ip dns set allow-remote-requests=yes

Configure basic firewall (LAN protection)

/ip firewall filter
add chain=input action=accept connection-state=established,related comment=“Accept established and related connections”
add chain=input action=drop connection-state=invalid comment=“Drop invalid connections”
add chain=input action=accept protocol=icmp comment=“Accept ICMP (ping)”
add chain=input action=drop in-interface-list=!LAN comment=“Drop all from WAN not destined to LAN”
add chain=forward action=accept connection-state=established,related comment=“Accept established and related connections”
add chain=forward action=drop connection-state=invalid comment=“Drop invalid connections”
add chain=forward action=drop in-interface-list=WAN comment=“Drop all from WAN to LAN”

Save configuration

/system script run defconf

You guys need to stop messing around with ChatGPT and the like.
It makes you all dumber.
For example, if you were to use even a little bit of the intellect that all normal people have,
how can the rest of the code be executed after the reset command reboots the device?
Also, if the config is really clean, how in-interface-list=WAN can find the uncreated WAN list?

In short, using artificial intelligence makes users dumber.

Sharing some thougths of Rextended there are more problems with that script.

Two interfaces in one bridge that has DHCP client assigned.
If both interfaces somehow connect then which one would be used to pass the traffic?
Do both SSID share the same IP poool?
Settings for DNS that is not configured at all.
LAN list.
and “running” default script to “save” configuration?

Crazy … how could you even try to believe the ChatGPT?

Thinking if that topic should be closed or not to prevent that “knowledge” to spread?

BTW … there is a “Search” function of the forum: https://forum.mikrotik.com/search.php?keywords=connect+to+WiFi+hotel

Answers drop you into very informational topic how to solve the problem: http://forum.mikrotik.com/t/connect-to-hotel-wifi/178760/22

I’m new to MikroTik and scripting and wanted to get a basis to start off of. That obviously didn’t work.

So if you need to learn Italian, start by looking at examples of Swahili?



So, obviously is lost time. This forum is full of correct examples.