Advertisement
Guest User

Untitled

a guest
Apr 6th, 2016
185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 1.68 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. ### BEGIN INIT INFO
  4. # Provides:         init_firewall
  5. # Required-Start:   $local_fs
  6. # Should-Start:    
  7. # Required-Stop:    $local_fs
  8. # Should-Stop:
  9. # X-Start-Before:   $network
  10. # X-Start-After:    $network
  11. # Default-Start:    S
  12. # Default-Stop:     0 6
  13. # Short-Description:    iptables based firewall
  14. ### END INIT INFO
  15.  
  16. case "1" in
  17. 'start')
  18. iptables-restore > /usr/local/sbin/config_firewall
  19. ip6tables-restore > /usr/local/sbin/config_firewall
  20. echo "Starting Firewall"
  21. RETVAL=$?
  22. ;;
  23.  
  24. 'stop')
  25. iptables-save > /usr/local/sbin/config_firewall
  26. ip6tables-save > /usr/local/sbin/config_fierwall
  27. RETVAL=$?
  28. ;;
  29.  
  30. 'clean')
  31. #nettoie le parefeu aux valeurs ci-dessous.
  32.  
  33. ####IPv4####
  34.  
  35. iptables -t filter -F
  36. iptables -t nat -F
  37. iptables -t mangle -F
  38. iptables -t filter -P INPUT ACCEPT
  39. iptables -t filter -P OUTPUT ACCEPT
  40. iptables -t filter -P FORWARD ACCEPT
  41. iptables -t nat -P PREROUTING ACCEPT
  42. iptables -t nat -P POSTROUTING ACCEPT
  43. iptables -t nat -P INPUT ACCEPT
  44. iptables -t nat -P FORWARD ACCEPT
  45. iptables -t raw -P OUTPUT ACCEPT
  46. iptables -t raw -P PREROUTING ACCEPT
  47.  
  48. ####IPv6####
  49. ip6tables -t filter -F
  50. ip6tables -t nat -F
  51. ip6tables -t mangle -F
  52. ip6tables -t raw -F
  53. ip6tables -t filter -P INPUT ACCEPT
  54. ip6tables -t filter -P OUTPUT ACCEPT
  55. ip6tables -t filter -P FORWARD ACCEPT
  56. ip6tables -t nat -P PREROUTING ACCEPT
  57. ip6tables -t nat -P POSTROUTING ACCEPT
  58. ip6tables -t nat -P OUTPUT ACCEPT
  59. ip6tables -t nat -P FORWARD ACCEPT
  60. ip6tables -t nat -P INPUT ACCEPT
  61. ip6tables -t raw -P OUTPUT ACCEPT
  62. ip6tables -t raw -P PREROUTING ACCEPT
  63.  
  64. RETVAL=$?
  65. ;;
  66.  
  67. 'restart')
  68. $0 stop && $0 start
  69. RETVAL=$?
  70. ;;
  71.  
  72. *)
  73. echo"Usage: $0 {start | stop | restart | clean }"
  74. RETVAL=1
  75. ;;
  76.  
  77. esac
  78. exit $RETVAL
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement