Advertisement
Guest User

Untitled

a guest
Sep 26th, 2017
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.68 KB | None | 0 0
  1. #!/bin/sh
  2.  
  3. # Vider les tables actuelles
  4. iptables -t filter -F
  5.  
  6. # Vider les règles personnelles
  7. iptables -t filter -X
  8.  
  9. # Interdire toute connexion entrante et sortante
  10. iptables -t filter -P INPUT DROP
  11. iptables -t filter -P FORWARD DROP
  12. iptables -t filter -P OUTPUT DROP
  13.  
  14. # ---
  15.  
  16. # Ne pas casser les connexions etablies
  17. iptables -A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  18. iptables -A OUTPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
  19.  
  20. # Autoriser loopback
  21. iptables -t filter -A INPUT -i lo -j ACCEPT
  22. iptables -t filter -A OUTPUT -o lo -j ACCEPT
  23.  
  24. # ICMP (Ping)
  25. iptables -t filter -A INPUT -p icmp -j ACCEPT
  26. iptables -t filter -A OUTPUT -p icmp -j ACCEPT
  27.  
  28. # ---
  29.  
  30. # SSH In
  31. iptables -t filter -A INPUT -p tcp --dport 22 -j ACCEPT
  32.  
  33. # SSH Out
  34. iptables -t filter -A OUTPUT -p tcp --dport 22 -j ACCEPT
  35.  
  36. # DNS In/Out
  37. iptables -t filter -A OUTPUT -p tcp --dport 53 -j ACCEPT
  38. iptables -t filter -A OUTPUT -p udp --dport 53 -j ACCEPT
  39. iptables -t filter -A INPUT -p tcp --dport 53 -j ACCEPT
  40. iptables -t filter -A INPUT -p udp --dport 53 -j ACCEPT
  41.  
  42. # NTP Out
  43. iptables -t filter -A OUTPUT -p udp --dport 123 -j ACCEPT
  44.  
  45. # HTTP + HTTPS Out
  46. iptables -t filter -A OUTPUT -p tcp --dport 80 -j ACCEPT
  47. iptables -t filter -A OUTPUT -p tcp --dport 443 -j ACCEPT
  48.  
  49.  
  50. # FTP Out
  51. iptables -t filter -A OUTPUT -p tcp --dport 20:21 -j ACCEPT
  52.  
  53. # FTP In
  54. modprobe ip_conntrack_ftp # ligne facultative avec les serveurs OVH
  55. iptables -t filter -A INPUT -p tcp --dport 20:21 -j ACCEPT
  56. iptables -t filter -A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT
  57.  
  58. # Mail SMTP:25
  59. iptables -t filter -A INPUT -p tcp --dport 25 -j ACCEPT
  60. iptables -t filter -A OUTPUT -p tcp --dport 25 -j ACCEPT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement