default 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. ## AFWall+ additional firewall rules
  2. ## Mike Kuketz
  3. ## www.kuketz-blog.de
  4. IPTABLES=/system/bin/iptables
  5. IP6TABLES=/system/bin/ip6tables
  6. # All 'afwall' chains/rules gets flushed automatically, before the custom script is executed
  7. # Flush/Purge all rules expect OUTPUT (quits with error)
  8. $IPTABLES -F INPUT
  9. $IPTABLES -F FORWARD
  10. $IPTABLES -t nat -F
  11. $IPTABLES -t mangle -F
  12. $IP6TABLES -F INPUT
  13. $IP6TABLES -F FORWARD
  14. $IP6TABLES -t nat -F
  15. $IP6TABLES -t mangle -F
  16. # Flush/Purge all chains
  17. $IPTABLES -X
  18. $IPTABLES -t nat -X
  19. $IPTABLES -t mangle -X
  20. $IP6TABLES -X
  21. $IP6TABLES -t nat -X
  22. $IP6TABLES -t mangle -X
  23. # Default deny connections
  24. $IP6TABLES -P INPUT DROP
  25. $IP6TABLES -P FORWARD DROP
  26. $IP6TABLES -P OUTPUT DROP
  27. $IPTABLES -P INPUT DROP
  28. $IPTABLES -P FORWARD DROP
  29. $IPTABLES -P OUTPUT DROP
  30. ####################
  31. # Tweaks #
  32. ####################
  33. ## Kernel
  34. # Disable IPv6
  35. echo 0 > /proc/sys/net/ipv6/conf/wlan0/accept_ra
  36. echo 1 > /proc/sys/net/ipv6/conf/all/disable_ipv6
  37. echo 1 > /proc/sys/net/ipv6/conf/default/disable_ipv6
  38. # Privacy IPv6 Address
  39. echo 2 > /proc/sys/net/ipv6/conf/all/use_tempaddr
  40. echo 2 > /proc/sys/net/ipv6/conf/default/use_tempaddr
  41. # Allow loopback interface lo
  42. $IPTABLES -A INPUT -i lo -j ACCEPT
  43. $IPTABLES -A "afwall" -o lo -j ACCEPT
  44. ##################### # Incoming Traffic # #####################
  45. # Allow ICMP packets
  46. $IPTABLES -A INPUT -p icmp -m icmp --icmp-type echo-reply -j ACCEPT
  47. $IPTABLES -A INPUT -p icmp -m icmp --icmp-type echo-request -j ACCEPT
  48. $IPTABLES -A INPUT -p icmp -m icmp --icmp-type destination-unreachable -j ACCEPT
  49. # Allow all traffic from an established #connection
  50. $IPTABLES -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  51. # Alle Pakete ordentlich zurückweisen
  52. $IPTABLES -A INPUT -p tcp -j REJECT --reject-with tcp-reset
  53. $IPTABLES -A INPUT -j REJECT --reject-with icmp-port-unreachable