10-vpnclient-unset-firewall 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. #!/bin/bash
  2. is_firewall_set() {
  3. ip6tables -w -nvL OUTPUT | grep vpnclient_out | grep -q "${wired_device}" \
  4. && iptables -w -nvL OUTPUT | grep vpnclient_out | grep -q "${wired_device}"
  5. }
  6. wired_device=$(ip route | awk '/default via/ { print $5; }')
  7. if is_firewall_set; then
  8. rm -f /etc/yunohost/hooks.d/post_iptable_rules/90-vpnclient
  9. # IPv4
  10. iptables -w -D INPUT -i "${wired_device}" -j vpnclient_in
  11. iptables -w -D OUTPUT -o "${wired_device}" -j vpnclient_out
  12. iptables -w -D FORWARD -o "${wired_device}" -j vpnclient_fwd
  13. iptables -w -F vpnclient_in
  14. iptables -w -F vpnclient_out
  15. iptables -w -F vpnclient_fwd
  16. iptables -w -X vpnclient_in
  17. iptables -w -X vpnclient_out
  18. iptables -w -X vpnclient_fwd
  19. # IPv6
  20. ip6tables -w -D INPUT -i "${wired_device}" -j vpnclient_in
  21. ip6tables -w -D OUTPUT -o "${wired_device}" -j vpnclient_out
  22. ip6tables -w -D FORWARD -o "${wired_device}" -j vpnclient_fwd
  23. ip6tables -w -F vpnclient_in
  24. ip6tables -w -F vpnclient_out
  25. ip6tables -w -F vpnclient_fwd
  26. ip6tables -w -X vpnclient_in
  27. ip6tables -w -X vpnclient_out
  28. ip6tables -w -X vpnclient_fwd
  29. fi