blob: 42e97cb38a805aee299d43bbefee3d946059efdf (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!/bin/sh -e
. ../common.sh
# setup random ip
net=$( uci get cloud.cur.net_robinson)
net_fake=$(uci get cloud.cur.net_fake)
prefix=$(ipcalc.sh $net | grep ^PREFIX | cut -f2 -d=)
gen_randip () {
local r=$RANDOM
randip=$(
ipcalc.sh $net $((($r % 2**(24 - $prefix) - 1) * 2**8 + 1)) 1 \
| grep ^START | cut -f2 -d=
)
}
gen_randip
while ! arping -I br-mesh -D -c 5 -q $randip; do
gen_randip
done
mesh_add_ipv4 $randip 255.0.0.0
# setup dhcp, start fake DNS
echo "
set dhcp.mesh=dhcp
set dhcp.mesh.start=3
set dhcp.mesh.limit=254
set dhcp.mesh.leasetime=60
set dhcp.mesh.interface=mesh
set dhcp.fakedns=domain
set dhcp.fakedns.ip=$(ipcalc.sh $net_fake 1 0 | grep ^START | cut -f2 -d=)
set dhcp.fakedns.name='#'
" | uci batch
/etc/init.d/dnsmasq restart
# disable batman-adv-mangling with DHCP packets
batctl gw off
# start redirection httpd, add robinson IP to service httpd
echo "http://$randip/robinson.html" > /tmp/redirection_target
enable_httpd redirection $randip:81
change_service_httpd_listen $randip:80
/etc/init.d/uhttpd restart
# redirect all tcp traffic to local httpd, all dns traffic to local NS
iptables -t nat -F prerouting_robinson_fake
iptables -t nat -F prerouting_robinson_inet
iptables -t nat -A prerouting_robinson_inet -p tcp \
-j DNAT --to-destination $randip:81
iptables -t nat -A prerouting_robinson_inet -p udp --dport 53 \
-j DNAT --to-destination $randip:53
|