1 #!/bin/sh /etc/rc.common
7 config_get zone "$cfg" zone
8 [ -n "$zone" ] || return 0
10 config_get net "$cfg" network
11 [ -n "$net" ] || return 0
13 config_get ipaddr "$net" ipaddr
14 [ -n "$ipaddr" ] || return 0
16 config_get netmask "$net" netmask
17 [ -n "$netmask" ] || return 0
19 eval "$(ipcalc.sh $ipaddr $netmask)"
21 iptables -t nat -A zone_${zone}_prerouting -s "$NETWORK/$PREFIX" -p ! tcp -j luci_splash_portal
22 iptables -t nat -A zone_${zone}_prerouting -s "$NETWORK/$PREFIX" -d ! "$ipaddr" -j luci_splash_portal
23 iptables -t nat -A zone_${zone}_prerouting -s "$NETWORK/$PREFIX" -d "$ipaddr" -p tcp -m multiport ! --dport 22,80,443 -j luci_splash_portal
29 config_get mac "$cfg" mac
30 [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
36 config_get mac "$cfg" mac
37 [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
41 ### Read chains from config
44 config_load luci_splash
47 iptables -t nat -N luci_splash
48 iptables -t nat -N luci_splash_portal
49 iptables -t nat -N luci_splash_leases
51 ### Build the main and portal rule
52 config_foreach blacklist_add blacklist
53 config_foreach whitelist_add whitelist
54 config_foreach iface_add iface
56 ### Build the portal rule
57 iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
58 iptables -t nat -A luci_splash_portal -j luci_splash_leases
60 ### Build the leases rule
61 iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
62 iptables -t nat -A luci_splash_leases -j DROP
65 grep luci-splash /var/spool/cron/crontabs/root >/dev/null 2>&1 || {
66 echo '*/5 * * * * /usr/sbin/luci-splash sync' >> /var/spool/cron/crontabs/root
69 ### Start the splash httpd
70 start-stop-daemon -S -b -q -x /usr/bin/luci-splashd
75 iptables -t nat -F luci_splash_leases
76 iptables -t nat -F luci_splash_portal
77 iptables -t nat -F luci_splash
80 iptables -t nat -X luci_splash_leases
81 iptables -t nat -X luci_splash_portal
82 iptables -t nat -X luci_splash
84 ### Stop the splash httpd
85 start-stop-daemon -K -q -x /usr/bin/luci-splashd