|
@@ -49,6 +49,17 @@ mwan3_set_general_iptables()
|
49
|
49
|
$IPT -F mwan3_rules
|
50
|
50
|
}
|
51
|
51
|
|
|
52
|
+mwan3_set_general_rules()
|
|
53
|
+{
|
|
54
|
+ if [ -z "$($IP rule list | awk '$1 == "2253:"')" ]; then
|
|
55
|
+ $IP rule add pref 2253 fwmark 0xfd00/0xff00 blackhole
|
|
56
|
+ fi
|
|
57
|
+
|
|
58
|
+ if [ -z "$($IP rule list | awk '$1 == "2254:"')" ]; then
|
|
59
|
+ $IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
|
|
60
|
+ fi
|
|
61
|
+}
|
|
62
|
+
|
52
|
63
|
mwan3_set_connected_iptables()
|
53
|
64
|
{
|
54
|
65
|
local connected_networks
|
|
@@ -112,18 +123,8 @@ mwan3_set_iface_rules()
|
112
|
123
|
$IP rule del pref $(($iface_id+2000))
|
113
|
124
|
done
|
114
|
125
|
|
115
|
|
- while [ -n "$($IP rule list | awk '$1 == "2253:"')" ]; do
|
116
|
|
- $IP rule del pref 2253
|
117
|
|
- done
|
118
|
|
-
|
119
|
|
- while [ -n "$($IP rule list | awk '$1 == "2254:"')" ]; do
|
120
|
|
- $IP rule del pref 2254
|
121
|
|
- done
|
122
|
|
-
|
123
|
126
|
[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+1000)) iif $DEVICE lookup main
|
124
|
127
|
[ $ACTION == "ifup" ] && $IP rule add pref $(($iface_id+2000)) fwmark $(($iface_id*256))/0xff00 lookup $iface_id
|
125
|
|
- $IP rule add pref 2253 fwmark 0xfd00/0xff00 blackhole
|
126
|
|
- $IP rule add pref 2254 fwmark 0xfe00/0xff00 unreachable
|
127
|
128
|
}
|
128
|
129
|
|
129
|
130
|
mwan3_track()
|
|
@@ -136,6 +137,11 @@ mwan3_track()
|
136
|
137
|
}
|
137
|
138
|
config_list_foreach $INTERFACE track_ip mwan3_list_track_ips
|
138
|
139
|
|
|
140
|
+ if [ -e /var/run/mwan3track-$INTERFACE.pid ] ; then
|
|
141
|
+ kill $(cat /var/run/mwan3track-$INTERFACE.pid) &> /dev/null
|
|
142
|
+ rm /var/run/mwan3track-$INTERFACE.pid &> /dev/null
|
|
143
|
+ fi
|
|
144
|
+
|
139
|
145
|
if [ -n "$track_ips" ]; then
|
140
|
146
|
config_get reliability $INTERFACE reliability 1
|
141
|
147
|
config_get count $INTERFACE count 1
|
|
@@ -299,7 +305,7 @@ mwan3_ifupdown()
|
299
|
305
|
sleep 1
|
300
|
306
|
let counter++
|
301
|
307
|
if [ "$counter" -ge 10 ]; then
|
302
|
|
- $LOG warn "Could not find gateway for interface $INTERFACE (${DEVICE:-unknown})" && return 0
|
|
308
|
+ $LOG warn "Could not find gateway for interface $INTERFACE ($DEVICE)" && return 0
|
303
|
309
|
fi
|
304
|
310
|
done
|
305
|
311
|
|
|
@@ -318,6 +324,7 @@ mwan3_ifupdown()
|
318
|
324
|
$LOG notice "$ACTION interface $INTERFACE (${DEVICE:-unknown})"
|
319
|
325
|
|
320
|
326
|
mwan3_set_general_iptables
|
|
327
|
+ mwan3_set_general_rules
|
321
|
328
|
mwan3_set_iface_iptables
|
322
|
329
|
mwan3_set_iface_route
|
323
|
330
|
mwan3_set_iface_rules
|
|
@@ -328,14 +335,15 @@ mwan3_ifupdown()
|
328
|
335
|
config_foreach mwan3_set_user_rules_iptables rule
|
329
|
336
|
}
|
330
|
337
|
|
331
|
|
-local IP IPT LOG
|
332
|
|
-
|
|
338
|
+[ -n "$ACTION" ] || exit 0
|
333
|
339
|
[ -n "$INTERFACE" ] || exit 0
|
334
|
340
|
|
335
|
341
|
if [ $ACTION == "ifup" ]; then
|
336
|
342
|
[ -n "$DEVICE" ] || exit 0
|
337
|
343
|
fi
|
338
|
344
|
|
|
345
|
+local IP IPT LOG
|
|
346
|
+
|
339
|
347
|
IP="/usr/sbin/ip -4"
|
340
|
348
|
IPT="/usr/sbin/iptables -t mangle -w"
|
341
|
349
|
LOG="/usr/bin/logger -t mwan3 -p"
|