-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathjailbox-stop
executable file
·55 lines (46 loc) · 1.32 KB
/
jailbox-stop
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
53
54
55
#!/bin/bash
if [ $UID -ne 0 ]; then
echo "Superuser rights required" >&2
exit 2
fi
source /etc/jailbox/config
if [[ "${PreStop}" ]]; then
bash -c "${PreStop}"
fi
for pid in $(cat ${tor_dir}*/tor.pid); do
kill $pid
done
#ip netns delete ${namespace}
#ip link delete ${veth_iface}
_chain_postrouting="${TAG}-POSTROUTING"
_chain_output="${TAG}-OUTPUT"
_chain_input="${TAG}-INPUT"
_chain_forward="${TAG}-FORWARD"
iptables -t nat -D POSTROUTING -j ${_chain_postrouting}
iptables -t nat -D OUTPUT -j ${_chain_output}
iptables -D FORWARD -j ${_chain_forward}
iptables -D INPUT -j ${_chain_input}
iptables -D OUTPUT -j ${_chain_output}
iptables -t nat -F ${_chain_postrouting}
iptables -t nat -F ${_chain_output}
iptables -F ${_chain_forward}
iptables -F ${_chain_input}
iptables -F ${_chain_output}
iptables -t nat -X ${_chain_postrouting}
iptables -t nat -X ${_chain_output}
iptables -X ${_chain_forward}
iptables -X ${_chain_input}
iptables -X ${_chain_output}
#iptables-save | grep -v "${TAG}" | iptables-restore
# set permissive policies
iptables -P INPUT ACCEPT
iptables -P OUTPUT ACCEPT
iptables -P FORWARD DROP
cat /dev/null >/etc/resolv.conf
for _nameserver in ${default_nameservers}; do
echo "nameserver ${_nameserver}" >>/etc/resolv.conf
done
#rm -rf "/etc/netns/${namespace}"
if [[ "${PostStop}" ]]; then
bash -c "${PostStop}"
fi