the stuff

heads-torify 679B

1234567891011121314151617181920212223242526272829303132333435363738
  1. #!/bin/sh
  2. #
  3. # Copyright (c) 2016-2018 Ivan J. <parazyd@dyne.org>
  4. # See LICENSE file for copyright and license details.
  5. #
  6. # experimental rude torifying
  7. flush_iptables() {
  8. printf "(*) flushing iptables rules\n"
  9. iptables -F
  10. iptables -t nat -F
  11. }
  12. load_iptables() {
  13. printf "(*) applying iptables rules\n"
  14. iptables-restore < /usr/local/lib/heads/iptables.rules
  15. printf "(*) done!\n"
  16. }
  17. case "x$1" in
  18. x-l)
  19. load_iptables
  20. printf "nameserver 127.0.0.1\n" > /etc/resolv.conf
  21. chattr +i /etc/resolv.conf
  22. ;;
  23. x-f)
  24. flush_iptables
  25. chattr -i /etc/resolv.conf
  26. ;;
  27. *)
  28. cat <<EOM
  29. usage: $(basename $0) [-l] [-f]
  30. -l) load iptables rules
  31. -f) flush iptables rules
  32. EOM
  33. ;;
  34. esac