Hi all.
I am using OpenWrt 24.10.0 and got OpenNDS to run with the hint: opennds.@opennds[0].use_outdated_mhd='1' option login_option_enabled '1' option login_option_enabled '2' working for me.
option login_option_enabled '3' the captive portal appears and when I try to log in with username and password I am redirected to the next page and click on the Continue button. When I do this, it takes me back to the first page. So I can't get on the network.
Can someone look at my problem?
/etc/config/opennds
opennds.@opennds[0]=opennds
opennds.@opennds[0].enabled='1'
opennds.@opennds[0].debuglevel='2'
opennds.@opennds[0].login_option_enabled='3'
opennds.@opennds[0].themespec_path='/usr/lib/opennds/ThemeSpec.sh'
opennds.@opennds[0].use_outdated_mhd='1'
opennds.@opennds[0].gatewayinterface='phy1-ap1'
opennds.@opennds[0].gatewayname='Wlan'
opennds.@opennds[0].binauth='/usr/lib/opennds/my_binauth_script.sh'
opennds.@opennds[0].faskey='b094b9692a41c9e7d4e87913d7bec09adf029b9e83db2a0fb14dce5e913343a6'
/usr/lib/opennds/my_binauth_script.sh
#!/bin/sh
# Pfad zur Benutzerdatei
USER_FILE="/etc/opennds/users.list"
# Lese die vom Client übermittelten Daten (werden von openNDS als Umgebungsvariablen bereitgestellt)
CLIENT_USER="$AUTH_USER"
CLIENT_PASS="$AUTH_PASS"
CLIENT_MAC="$CLIENTMAC" # Nur zur Info/Logging, falls gewünscht
# Debugging-Ausgabe (optional, nützlich bei Problemen)
# logger -t binauth "Login attempt: User='$CLIENT_USER', Pass='******', MAC='$CLIENT_MAC'"
# Prüfe, ob Benutzername und Passwort übergeben wurden
if [ -z "$CLIENT_USER" ] || [ -z "$CLIENT_PASS" ]; then
# logger -t binauth "Login failed: Empty username or password. MAC: $CLIENT_MAC"
exit 1 # Fehlschlag
fi
# Suche den Benutzer in der Datei und prüfe das Passwort
# Format in users.list: username:password
EXPECTED_PASS=$(grep "^${CLIENT_USER}:" "$USER_FILE" | cut -d':' -f2)
if [ -n "$EXPECTED_PASS" ] && [ "$CLIENT_PASS" = "$EXPECTED_PASS" ]; then
# Passwort stimmt überein
# logger -t binauth "Login successful: User='$CLIENT_USER', MAC='$CLIENT_MAC'"
exit 0 # Erfolg -> openNDS gewährt Zugang
else
# Falscher Benutzername oder falsches Passwort
# logger -t binauth "Login failed: Invalid credentials for User='$CLIENT_USER'. MAC: $CLIENT_MAC"
exit 1 # Fehlschlag -> openNDS verweigert Zugang
fi
/usr/lib/opennds/ThemeSpec.sh
#!/bin/sh
# Lese Variablen von openNDS (optional, aber nützlich)
gatewayname="$GATEWAYNAME"
clientip="$CLIENTIP"
clientmac="$CLIENTMAC"
authaction="$AUTH_ACTION" # Die URL, an die das Formular gesendet werden muss
# Generiere den HTML-Code
cat << EOF
<!DOCTYPE html>
<html lang="de">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Willkommen bei $gatewayname</title>
<style>
body {
font-family: sans-serif;
background-color: #f4f4f4;
margin: 0;
padding: 20px;
display: flex;
justify-content: center;
align-items: center;
min-height: 100vh;
}
.container {
background-color: #fff;
padding: 30px;
border-radius: 8px;
box-shadow: 0 2px 10px rgba(0,0,0,0.1);
max-width: 500px;
width: 100%;
text-align: center;
}
h1 {
color: #333;
margin-bottom: 20px;
}
label {
display: block;
margin-bottom: 5px;
color: #555;
text-align: left;
}
input[type="text"], input[type="password"] {
width: calc(100% - 22px); /* Adjust for padding/border */
padding: 10px;
margin-bottom: 15px;
border: 1px solid #ccc;
border-radius: 4px;
}
button {
background-color: #5cb85c;
color: white;
padding: 12px 20px;
border: none;
border-radius: 4px;
cursor: pointer;
font-size: 16px;
transition: background-color 0.3s;
}
button:hover {
background-color: #4cae4c;
}
.info, .disclaimer {
margin-top: 25px;
font-size: 0.9em;
color: #666;
text-align: left;
padding-top: 15px;
border-top: 1px solid #eee;
}
.disclaimer {
font-size: 0.8em;
color: #888;
}
.price-info {
font-weight: bold;
color: #337ab7; /* Blue color for emphasis */
}
</style>
</head>
<body>
<div class="container">
<h1>Willkommen bei "$gatewayname"</h1>
<p>Bitte melden Sie sich an, um das Internet zu nutzen.</p>
<form method="POST" action="$authaction">
<div>
<label for="auth_user">Benutzername:</label>
<input type="text" id="auth_user" name="auth_user" required>
</div>
<div>
<label for="auth_pass">Passwort:</label>
<input type="password" id="auth_pass" name="auth_pass" required>
</div>
<button type="submit">Anmelden</button>
</form>
<div class="info">
<p class="price-info">Dieser WLAN-Zugang wird für 20€ pro Monat angeboten.</p>
<p>Kontaktieren Sie den Betreiber für Zugangsdaten.</p>
</div>
<div class="disclaimer">
<h2>Haftungsausschluss</h2>
<p>Die Nutzung dieses WLAN-Zugangs erfolgt auf eigene Gefahr. Der Betreiber übernimmt keine Haftung für Schäden, die durch die Nutzung entstehen. Es ist untersagt, rechtswidrige Handlungen vorzunehmen (z. B. Urheberrechtsverletzungen). Der Betreiber speichert keine personenbezogenen Daten und behält sich vor, bei Verdacht auf Missbrauch den Zugang zu sperren.</p>
</div>
</div>
</body>
</html>
EOF
exit 0
/etc/opennds/users.list
user1:123456748
kundeA:passwortXYZ
gast123:geheim456
ThemeSpec Path
ThemeSpec Path
Default: None
Required when when login_option_enabled is set to ‘3’
Note: /usr/lib/opennds/theme_click-to-continue.sh is used for login_option_enabled ‘1’
and: /usr/lib/opennds/theme_user_email_login.sh is used for login_option_enabled ‘2’
Sets the ThemeSpec file path to be used when login_option_enabled ‘3’
The ThemeSpec script makes use of lists of custom parameters, custom variables, custom image urls and custom files and is used to generate the dynamic splash page sequence.
The ThemeSpec file will normally reside in /usr/lib/opennds/ but can be anywhere accessible to openNDS.
The file must be flagged as executable and have the correct shebang for the default shell.
Default: None
Required when when login_option_enabled is set to ‘3’
Note: /usr/lib/opennds/theme_click-to-continue.sh is used for login_option_enabled ‘1’
and: /usr/lib/opennds/theme_user_email_login.sh is used for login_option_enabled ‘2’
Sets the ThemeSpec file path to be used when login_option_enabled ‘3’
The ThemeSpec script makes use of lists of custom parameters, custom variables, custom image urls and custom files and is used to generate the dynamic splash page sequence.
The ThemeSpec file will normally reside in /usr/lib/opennds/ but can be anywhere accessible to openNDS.
The file must be flagged as executable and have the correct shebang for the default shell.