Advertisement
Guest User

Untitled

a guest
Dec 22nd, 2014
314
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.22 KB | None | 0 0
  1. #
  2. # rules.before
  3. #
  4. # Rules that should be run before the ufw command line added rules. Custom
  5. # rules should be added to one of these chains:
  6. # ufw-before-input
  7. # ufw-before-output
  8. # ufw-before-forward
  9. #
  10.  
  11. # Don't delete these required lines, otherwise there will be errors
  12. *filter
  13. :ufw-before-input - [0:0]
  14. :ufw-before-output - [0:0]
  15. :ufw-before-forward - [0:0]
  16. :ufw-not-local - [0:0]
  17. # End required lines
  18.  
  19. # allow all on loopback
  20. -A ufw-before-input -i lo -j ACCEPT
  21. -A ufw-before-output -o lo -j ACCEPT
  22.  
  23. # quickly process packets for which we already have a connection
  24. -A ufw-before-input -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  25. -A ufw-before-output -m conntrack --ctstate RELATED,ESTABLISHED -j ACCEPT
  26.  
  27. # drop INVALID packets (logs these in loglevel medium and higher)
  28. -A ufw-before-input -m conntrack --ctstate INVALID -j ufw-logging-deny
  29. -A ufw-before-input -m conntrack --ctstate INVALID -j DROP
  30.  
  31. # ok icmp codes
  32. -A ufw-before-input -p icmp --icmp-type destination-unreachable -j ACCEPT
  33. -A ufw-before-input -p icmp --icmp-type source-quench -j ACCEPT
  34. -A ufw-before-input -p icmp --icmp-type time-exceeded -j ACCEPT
  35. -A ufw-before-input -p icmp --icmp-type parameter-problem -j ACCEPT
  36. -A ufw-before-input -p icmp --icmp-type echo-request -j ACCEPT
  37.  
  38. # allow dhcp client to work
  39. -A ufw-before-input -p udp --sport 67 --dport 68 -j ACCEPT
  40.  
  41. #
  42. # ufw-not-local
  43. #
  44. -A ufw-before-input -j ufw-not-local
  45.  
  46. # if LOCAL, RETURN
  47. -A ufw-not-local -m addrtype --dst-type LOCAL -j RETURN
  48.  
  49. # if MULTICAST, RETURN
  50. -A ufw-not-local -m addrtype --dst-type MULTICAST -j RETURN
  51.  
  52. # if BROADCAST, RETURN
  53. -A ufw-not-local -m addrtype --dst-type BROADCAST -j RETURN
  54.  
  55. # all other non-local packets are dropped
  56. -A ufw-not-local -m limit --limit 3/min --limit-burst 10 -j ufw-logging-deny
  57. -A ufw-not-local -j DROP
  58.  
  59. # allow MULTICAST mDNS for service discovery (be sure the MULTICAST line above
  60. # is uncommented)
  61. -A ufw-before-input -p udp -d 224.0.0.251 --dport 5353 -j ACCEPT
  62.  
  63. # allow MULTICAST UPnP for service discovery (be sure the MULTICAST line above
  64. # is uncommented)
  65. -A ufw-before-input -p udp -d 239.255.255.250 --dport 1900 -j ACCEPT
  66.  
  67. # don't delete the 'COMMIT' line or these rules won't be processed
  68. COMMIT
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement