home *** CD-ROM | disk | FTP | other *** search
/ chilidog.highland.cc.ks.us / chilidog.highland.cc.ks.us.zip / chilidog.highland.cc.ks.us / backup / bradford.20100913.bsc-siteConfiguration.tar.gz / bradford.20100913.bsc-siteConfiguration.tar / bsc / siteConfiguration / firewall < prev    next >
Text File  |  2008-03-31  |  4KB  |  103 lines

  1. #!/bin/sh
  2.  
  3. # Start with a clean slate
  4. iptables --flush
  5.  
  6. # For 4.0 -- Don't apply these rules
  7. exit 0;
  8.  
  9. #eth1:
  10.  
  11. # Allow DNS
  12. iptables -A INPUT --in-interface eth1 -p UDP --dport 53 -j ACCEPT
  13.  
  14. # Allow DHCP
  15. iptables -A INPUT --in-interface eth1 -p UDP --dport 67 -j ACCEPT
  16.  
  17. # Allow HTTP
  18. iptables -A INPUT --in-interface eth1 -p TCP --dport 80 -j ACCEPT
  19.  
  20. # Allow HTTPS
  21. iptables -A INPUT --in-interface eth1 -p TCP --dport 443 -j ACCEPT
  22.  
  23. # Allow Agent protocol
  24. iptables -A INPUT --in-interface eth1 -p UDP --dport 4567 -j ACCEPT
  25.  
  26. # Drop Any other packets
  27. iptables -A INPUT --in-interface eth1 -j DROP
  28.  
  29.  
  30. #eth0
  31.  
  32. # Management Process
  33. iptables -A INPUT --in-interface eth0 -p UDP --dport 5555 -j ACCEPT
  34. iptables -A INPUT --in-interface eth0 -p UDP --dport 5556 -j ACCEPT
  35.  
  36. # HTTP Mgmt
  37. iptables -A INPUT --in-interface eth0 -p TCP --dport 8080 -j ACCEPT
  38. iptables -A INPUT --in-interface eth0 -p TCP --dport 8443 -j ACCEPT
  39.  
  40. #ICMP
  41. iptables -A INPUT --in-interface eth0 -p ICMP -j ACCEPT
  42.  
  43. #mysql
  44. iptables -A INPUT --in-interface eth0 -p TCP --dport 3306 -j ACCEPT
  45.  
  46. # HTTP portal
  47. iptables -A INPUT --in-interface eth0 -p TCP --dport 443 -j ACCEPT
  48. iptables -A INPUT --in-interface eth0 -p TCP --dport 80 -j ACCEPT
  49.  
  50. # SSH
  51. iptables -A INPUT --in-interface eth0 -p TCP --dport 22 -j ACCEPT
  52.  
  53. # RADIUS
  54. iptables -A INPUT --in-interface eth0 -p UDP --dport 1646 -j ACCEPT
  55. iptables -A INPUT --in-interface eth0 -p UDP --dport 1812 -j ACCEPT
  56. iptables -A INPUT --in-interface eth0 -p UDP --dport 1813 -j ACCEPT
  57.  
  58. # LDAP
  59. iptables -A INPUT --in-interface eth0 -p TCP --dport 389
  60. iptables -A INPUT --in-interface eth0 -p TCP --dport 636
  61.  
  62. # SYSLOG
  63. iptables -A INPUT --in-interface eth0 -p UDP --dport 514
  64.  
  65.  
  66. # SNMP
  67. iptables -A INPUT --in-interface eth0 -p UDP --dport 161 -j ACCEPT
  68. iptables -A INPUT --in-interface eth0 -p UDP --dport 160 -j ACCEPT
  69.  
  70. # Allow Agent protocol
  71. iptables -A INPUT --in-interface eth0 -p UDP --dport 4567 -j ACCEPT
  72.  
  73. # CORBA Name Service
  74. iptables -A INPUT --in-interface eth0 -p TCP --dport 1050 -j ACCEPT
  75. # (for CORBA) Ports above 32000 -- NEEDS TESTING
  76. iptables -A INPUT --in-interface eth0 -p TCP --dport 32000: -j ACCEPT
  77.  
  78.  
  79.  
  80.  
  81. iptables -A INPUT --in-interface eth0 -j DROP
  82.  
  83.  
  84.  
  85. #####
  86. ### Customer-provided.  NEEDS TESTING
  87. #
  88. # set iptables limit on incoming port 80 to 10/minute with a burst of 30/minute (new sessions) per source IP
  89. # if the limit is exceeded, drop them for 300 seconds / 5 minutes.
  90. #
  91. /usr/bin/sudo /usr/sbin/iptables -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  92. /usr/bin/sudo /usr/sbin/iptables -A INPUT -i lo -j ACCEPT
  93. /usr/bin/sudo /usr/sbin/iptables -A INPUT -p tcp -m state --state NEW --dport 80 -m hashlimit --hashlimit-name httplimit --hashlimit-mode srcip --hashlimit 10/minute --hashlimit-burst 30 --hashlimit-htable-expire 300000 -j ACCEPT
  94. /usr/bin/sudo /usr/sbin/iptables -A INPUT -p tcp -m state --state NEW --dport 80 -m hashlimit --hashlimit-name floodlog --hashlimit-mode srcip --hashlimit 1/minute --hashlimit-burst 2 -j LOG --log-prefix "HTTP flood:"
  95. /usr/bin/sudo /usr/sbin/iptables -A INPUT -p tcp -m state --state NEW --dport 80 -j DROP
  96. #
  97. # set iptables limit on incoming DNS requests to catch Vista wpad/isatap flooding requests
  98. # typically these occur in thousands per second, we'll threshold at 300/sec (your mileage may vary)
  99. #
  100. /usr/bin/sudo /usr/sbin/iptables -A INPUT -p udp --dport 53 -m hashlimit --hashlimit-name dnslimit --hashlimit-mode srcip --hashlimit 300/sec --hashlimit-burst 500 --hashlimit-htable-expire 300000 -j ACCEPT
  101. /usr/bin/sudo /usr/sbin/iptables -A INPUT -p udp --dport 53 -m hashlimit --hashlimit-name dnslog --hashlimit-mode srcip --hashlimit 1/minute --hashlimit-burst 2 -j LOG --log-prefix "DNS flood:"
  102. /usr/bin/sudo /usr/sbin/iptables -A INPUT -p udp --dport 53 -j DROP 
  103.