Keeping alive the connection in AP mode


I have successfully installed OpenWRT and configured my router (TL-WR841N) in AP mode. However, when it is connecting to the main WiFi-network, a login to the captive portal is needed. After login in the morning, the connection is retained all day and only disappears after being inactive during the night.

Writing a script in Bash for automatic login is a problem for me, however I suppose simply keeping the connection alive would solve the problem.

Could you tell me how I could keep the connection, for example with
Which module should I install for this or can this script be written in the LuCI Web Interface?

Thx in advance for your support!

A script to poll is simple to create. You can just create a cron entry that would call curl and send output to /dev/null. Cron is a mechanism to periodically run a script/program.

For security, create a service user to do this, let's say "keepalive". Then create a file /etc/crontabs/keepalive and put a line in there to call curl every minute:

* * * * * /usr/bin/curl -s > /dev/null

The question here is, whether this will actually keep the session alive, but that depends on the captive portal. If that is configured to require a login e.g. after 24 hours, no matter what, this won't work and you would need a far more advanced script to perform the login.

  • Menno
1 Like

Thx a lot! I've read the "cron and crontab" guide, and will implement it soon.
Could you give a hint/link how to create a new service user?

On a "normal" linux system, you would use useradd. On OpenWRT, just add a line to /etc/passwd, with a unique name and unique uid number. Then create a line in /etc/shadow with * as the password to prevent logins. For the guid, you could pick an existing group or also add a line to /etc/group.

1 Like