iptables.rc 2.4 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #!/bin/sh
  2. ########################################################################
  3. # Begin iptables
  4. #
  5. # Tanım: Start iptables
  6. #
  7. # Authors : Ken Moffat - ken@linuxfromscratch.org
  8. # Bruce Dubbs - bdubbs@linuxfromscratch.org
  9. #
  10. # Version : LFS 7.0
  11. #
  12. ########################################################################
  13. ### BEGIN INIT INFO
  14. # Provides: iptables
  15. # Required-Start:
  16. # Should-Start:
  17. # Required-Stop: $local_fs
  18. # Should-Stop:
  19. # Default-Start: 3 4 5
  20. # Default-Stop:
  21. # Short-Tanım: Loads iptables rules.
  22. # Tanım: Iptables provides firewall for Linux systems.
  23. # X-LFS-Provided-By: BLFS / LFS 7.0
  24. ### END INIT INFO
  25. . /lib/lsb/init-functions
  26. #$LastChangedBy: krejzi $
  27. #$Date: 2013-06-11 11:01:46 -0500 (Tue, 11 Jun 2013) $
  28. case "$1" in
  29. start)
  30. if [ -x /etc/rc.d/rc.iptables ]; then
  31. log_info_msg "Starting iptables..."
  32. /etc/rc.d/rc.iptables
  33. evaluate_retval
  34. fi
  35. ;;
  36. lock)
  37. log_info_msg "Locking system iptables firewall..."
  38. /usr/sbin/iptables --policy INPUT DROP
  39. /usr/sbin/iptables --policy OUTPUT DROP
  40. /usr/sbin/iptables --policy FORWARD DROP
  41. /usr/sbin/iptables --flush
  42. /usr/sbin/iptables -t nat --flush
  43. /usr/sbin/iptables -t mangle --flush
  44. /usr/sbin/iptables --delete-chain
  45. /usr/sbin/iptables -t nat --delete-chain
  46. /usr/sbin/iptables -t mangle --delete-chain
  47. /usr/sbin/iptables -A INPUT -i lo -j ACCEPT
  48. /usr/sbin/iptables -A OUTPUT -o lo -j ACCEPT
  49. evaluate_retval
  50. ;;
  51. clear)
  52. log_info_msg "Clearing system iptables iptables..."
  53. /usr/sbin/iptables --policy INPUT ACCEPT
  54. /usr/sbin/iptables --policy OUTPUT ACCEPT
  55. /usr/sbin/iptables --policy FORWARD ACCEPT
  56. /usr/sbin/iptables --flush
  57. /usr/sbin/iptables -t nat --flush
  58. /usr/sbin/iptables -t mangle --flush
  59. /usr/sbin/iptables --delete-chain
  60. /usr/sbin/iptables -t nat --delete-chain
  61. /usr/sbin/iptables -t mangle --delete-chain
  62. evaluate_retval
  63. ;;
  64. status)
  65. /usr/sbin/iptables --numeric --list
  66. /usr/sbin/iptables -t nat --numeric --list
  67. /usr/sbin/iptables -t mangle --numeric --list
  68. ;;
  69. *)
  70. echo "Usage: $0 {start|clear|lock|status}"
  71. exit 1
  72. ;;
  73. esac
  74. # End /etc/init.d/iptables