mirror of
https://codeberg.org/prof_x_pvt_ltd/captive.whump.shanti-portal
synced 2024-08-14 22:46:42 +00:00
more docs and examples.
This commit is contained in:
parent
ea51951696
commit
5ece708067
5 changed files with 153 additions and 0 deletions
27
docs/examples/iptables/cp_iptables.sh.j2
Normal file
27
docs/examples/iptables/cp_iptables.sh.j2
Normal file
|
@ -0,0 +1,27 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
# Captiveportal iptables wrapper script
|
||||
#iptables_mac = iptables -t mangle -I internet 1 -m mac --mac-source {mac_address} -j RETURN
|
||||
|
||||
# First argument must be IP-address of client
|
||||
test -n "$1" || exit 1
|
||||
|
||||
client_ip="$1"
|
||||
ipt=/sbin/iptables
|
||||
|
||||
# Enable client traffic in internet chain by jumping over the mark
|
||||
$ipt -t mangle -I internet 1 -p tcp --source "$client_ip" -j RETURN &>/dev/null && \
|
||||
$ipt -t mangle -I internet 1 -p udp --source "$client_ip" -j RETURN &>/dev/null
|
||||
iptables_rc=$?
|
||||
|
||||
# Delete conntrack info for client IP
|
||||
/usr/local/sbin/rmtrack.sh "$client_ip" &>/dev/null
|
||||
rmtrack_rc=$?
|
||||
|
||||
if [[ $iptables_rc == 0 && $rmtrack_rc == 0 ]]; then
|
||||
# Success
|
||||
exit 0
|
||||
else
|
||||
echo "Error: iptables[$iptables_rc], rmtrack[$rmtrack_rc]" 1&>2
|
||||
exit 1
|
||||
fi
|
Loading…
Add table
Add a link
Reference in a new issue