Guest User

iptables

a guest
Jun 1st, 2018
380
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.27 KB | None | 0 0
  1. #### The mangle table
  2. # This table allows us to modify packet headers
  3. # Packets enter this table first
  4. #
  5. *mangle
  6.  
  7. :PREROUTING ACCEPT [0:0]
  8. :INPUT ACCEPT [0:0]
  9. :FORWARD ACCEPT [0:0]
  10. :OUTPUT ACCEPT [0:0]
  11. :POSTROUTING ACCEPT [0:0]
  12.  
  13. COMMIT
  14.  
  15.  
  16. #### The nat table
  17. # This table enables Network Address Translation
  18. # (This is technically a type of packet mangling)
  19. #
  20. *nat
  21.  
  22. :PREROUTING ACCEPT [0:0]
  23. :POSTROUTING ACCEPT [0:0]
  24.  
  25. # Allow traffic from the VPN network to the outside world, and replies
  26. -A POSTROUTING -s 192.168.5.0/24 -m policy --pol none --dir out -j MASQUERADE
  27.  
  28. COMMIT
  29.  
  30.  
  31. #### The filter table
  32. # The default ipfilter table
  33. #
  34. *filter
  35.  
  36. # By default, drop packets that are destined for this server
  37. :INPUT DROP [0:0]
  38. # By default, drop packets that request to be forwarded by this server
  39. :FORWARD DROP [0:0]
  40. # By default, accept any packets originating from this server
  41. :OUTPUT ACCEPT [0:0]
  42.  
  43. # Accept packets destined for localhost
  44. -A INPUT -i lo -j ACCEPT
  45. # Accept any packet from an open TCP connection
  46. -A INPUT -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  47. # Accept packets using the encapsulation protocol
  48. -A INPUT -p esp -j ACCEPT
  49. -A INPUT -p ah -j ACCEPT
  50. # rate limit ICMP traffic per source
  51. -A INPUT -p icmp --icmp-type echo-request -m hashlimit --hashlimit-upto 5/s --hashlimit-mode srcip --hashlimit-srcmask 32 --hashlimit-name icmp-echo-drop -j ACCEPT
  52. # Accept IPSEC traffic to ports 500 (IPSEC) and 4500 (MOBIKE aka IKE + NAT traversal)
  53. -A INPUT -p udp -m multiport --dports 500,4500 -j ACCEPT
  54. # Allow new traffic to port 22 (SSH)
  55. -A INPUT -p tcp --dport 22 -m conntrack --ctstate NEW -j ACCEPT
  56. # Allow any traffic from the VPN
  57. -A INPUT -p ipencap -m policy --dir in --pol ipsec --proto esp -j ACCEPT
  58.  
  59. # Forward any packet that's part of an established connection
  60. -A FORWARD -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  61. # Drop SMB/CIFS traffic that requests to be forwarded
  62. -A FORWARD -p tcp --dport 445 -j DROP
  63. # Drop NETBIOS trafic that requests to be forwarded
  64. -A FORWARD -p udp -m multiport --ports 137,138 -j DROP
  65. -A FORWARD -p tcp -m multiport --ports 137,139 -j DROP
  66.  
  67. # Forward any IPSEC traffic from the VPN network
  68. -A FORWARD -m conntrack --ctstate NEW -s 192.168.5.0/24 -m policy --pol ipsec --dir in -j ACCEPT
  69.  
  70. COMMIT
Advertisement
Add Comment
Please, Sign In to add comment