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 prerouting_${zone} -j luci_splash_prerouting
22 iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -p ! tcp -j luci_splash_portal
23 iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -d ! "$ipaddr" -j luci_splash_portal
24 iptables -t nat -A luci_splash_prerouting -s "$NETWORK/$PREFIX" -d "$ipaddr" -p tcp -m multiport ! --dport 22,80,443 -j luci_splash_portal
30 config_get mac "$cfg" mac
31 [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j DROP
37 config_get mac "$cfg" mac
38 [ -n "$mac" ] && iptables -t nat -A luci_splash_portal -m mac --mac-source "$mac" -j RETURN
42 ### Read chains from config
45 config_load luci_splash
48 iptables -t nat -N luci_splash_portal
49 iptables -t nat -N luci_splash_leases
50 iptables -t nat -N luci_splash_prerouting
52 ### Build the main and portal rule
53 config_foreach blacklist_add blacklist
54 config_foreach whitelist_add whitelist
55 config_foreach iface_add iface
57 ### Build the portal rule
58 iptables -t nat -A luci_splash_portal -p udp --dport 53 -j RETURN
59 iptables -t nat -A luci_splash_portal -j luci_splash_leases
61 ### Build the leases rule
62 iptables -t nat -A luci_splash_leases -p tcp --dport 80 -j REDIRECT --to-ports 8082
63 iptables -t nat -A luci_splash_leases -j DROP
66 grep luci-splash /var/spool/cron/crontabs/root >/dev/null 2>&1 || {
67 echo '*/5 * * * * /usr/sbin/luci-splash sync' >> /var/spool/cron/crontabs/root
70 ### Start the splash httpd
71 start-stop-daemon -S -b -q -x /usr/bin/luci-splashd
75 config_get zone "$1" zone
76 [ -n "$zone" ] || return 0
77 iptables -t nat -D prerouting_${zone} -j luci_splash_prerouting
81 ### Clear interface rules
82 config_load luci_splash
83 config_foreach iface_del iface
86 iptables -t nat -F luci_splash_leases
87 iptables -t nat -F luci_splash_portal
88 iptables -t nat -F luci_splash_prerouting
91 iptables -t nat -X luci_splash_leases
92 iptables -t nat -X luci_splash_portal
93 iptables -t nat -X luci_splash_prerouting
95 ### Stop the splash httpd
96 start-stop-daemon -K -q -x /usr/bin/luci-splashd