doc/gateway-server/WifiDogAndOlsr: WifidogHttpOLSR.sh

File WifidogHttpOLSR.sh, 1.0 KB (added by mmemeteau@…, 13 years ago)

the script itself with a correct name

Line 
1#!/bin/sh
2#
3# Script to bypass HTTP interception for traffic forwarded by OLSR
4# bms 9-Aug-2005
5# Licensed under GPL
6#
7
8rm -f /tmp/get_neighbors.awk
9cat > /tmp/get_neighbors.awk <<__HERE1__
10BEGIN {
11 while("route -n"|getline) {
12    if (/^[0-9]/) {
13        if (0 < \$5) {
14           if (\$3 == "255.255.255.255 <http://255.255.255.255>") {
15             printf "%s\n", \$1;
16                 }
17               }
18             }
19           }
20        }
21__HERE1__
22
23
24iptables -t nat -D WiFiDog_Unknown -j OlsrNeighbors 2>&1 >/dev/null
25iptables -t nat -F OlsrNeighbors 2>&1 >/dev/null
26iptables -t nat -X OlsrNeighbors 2>&1 >/dev/null
27iptables -t nat -N OlsrNeighbors
28
29neighbors=$(awk -f /tmp/get_neighbors.awk)
30
31for _neighbor in ${neighbors} ; do
32
33   _mac=$(grep "^${_neighbor}" /proc/net/arp | awk '{print $4}')
34   echo ${_mac}
35   iptables -t nat -A OlsrNeighbors -m mac --mac-source ${_mac} \
36          -p tcp --dport 80 -j ACCEPT
37         
38done
39
40iptables -t nat -I WiFiDog_Unknown -j OlsrNeighbors