File tree 2 files changed +9
-3
lines changed
2 files changed +9
-3
lines changed Original file line number Diff line number Diff line change @@ -43,8 +43,8 @@ def restart_wg():
43
43
return False
44
44
if resp .status_code == 200 :
45
45
logging .info ('[WG]: WG interface restarted' )
46
- remove_predowns ()
47
- fwd_predown_rules ()
46
+ # remove_predowns()
47
+ # fwd_predown_rules()
48
48
os .system (f'cp { wgconf } { wgconf } .bak' )
49
49
return True
50
50
else :
@@ -211,7 +211,7 @@ def rule_gen(rule,ad):
211
211
{ protocol } -d { peer } --dport { port } -j ACCEPT\n '
212
212
preroute_rule = f'{ prefix } = iptables -{ ad } PREROUTING \
213
213
-t nat -p { protocol } -i eth0 --dport { port } -j DNAT --to-destination \
214
- { peer } :{ port } \n '
214
+ { peer } :{ port } \n -m comment --comment "fwded" \n '
215
215
if rule == 'fwd' :
216
216
return fwd_rule
217
217
elif rule == 'pre' :
Original file line number Diff line number Diff line change 1
1
#! /bin/bash
2
+ # iptables --line-numbers --list
2
3
echo " Restarting WG interface..."
4
+ # Look for all rules that have the 'fwded' comment
5
+ FWD_RULES=$( iptables --line-number -nL FORWARD| grep fwded| awk ' {print $1}' | tac)
3
6
wg-quick down wg0
7
+ # Delete them (background)
8
+ for rul in $FWD_RULES ; do iptables -D FORWARD $rul ; done
9
+ sleep 0.1
4
10
wg-quick up wg0
You can’t perform that action at this time.
0 commit comments