Setting_up_IPSinline_for_Linux.txt 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. Autogenerated on 2012-11-29
  2. from - https://suricata.readthedocs.io/en/latest/setting-up-ipsinline-for-linux.html
  3. Setting up IPS/inline for Linux
  4. In this guide will be explained how to work with Suricata in inline mode and
  5. how to set iptables for that purpose.
  6. First start with compiling Suricata with NFQ support. For instructions see
  7. Ubuntu_Installation.
  8. For more information about NFQ and iptables, see suricata.yaml.
  9. To check if you have NFQ enabled in your Suricata, enter the following command:
  10. suricata --build-info
  11. and examine if you have NFQ between the features.
  12. To run suricata with the NFQ mode, you have to make use of the -q option. This
  13. option tells Suricata which of the queue numbers it should use.
  14. sudo suricata -c /etc/suricata/suricata.yaml -q 0
  15. Iptables configuration
  16. First of all it is important to know which traffic you would like to send to
  17. Suricata. Traffic that passes your computer or traffic that is generated by
  18. your computer.
  19. If Suricata is running on a gateway and is meant to protect the computers
  20. behind that gateway you are dealing with the first scenario: forward_ing .
  21. If Suricata has to protect the computer it is running on, you are dealing with
  22. the second scenario: host (see drawing 2).
  23. These two ways of using Suricata can also be combined.
  24. The easiest rule in case of the gateway-scenario to send traffic to Suricata
  25. is:
  26. sudo iptables -I FORWARD -j NFQUEUE
  27. In this case, all forwarded traffic goes to Suricata.
  28. In case of the host situation, these are the two most simple iptable rules;
  29. sudo iptables -I INPUT -j NFQUEUE
  30. sudo iptables -I OUTPUT -j NFQUEUE
  31. It is possible to set a queue number. If you do not, the queue number will be 0
  32. by default.
  33. Imagine you want Suricata to check for example just TCP-traffic, or all
  34. incoming traffic on port 80, or all traffic on destination-port 80, you can do
  35. so like this:
  36. sudo iptables -I INPUT -p tcp -j NFQUEUE
  37. sudo iptables -I OUTPUT -p tcp -j NFQUEUE
  38. In this case, Suricata checks just TCP traffic.
  39. sudo iptables -I INPUT -p tcp --sport 80 -j NFQUEUE
  40. sudo iptables -I OUTPUT -p tcp --dport 80 -j NFQUEUE
  41. In this example, Suricata checks all input and output on port 80.
  42. To see if you have set your iptables rules correct make sure Suricata is
  43. running and enter:
  44. sudo iptables -vnL
  45. In the example you can see if packets are being logged.
  46. This description of the use of iptables is the way to use it with IPv4. To use
  47. it with IPv6 all previous mentioned commands have to start with 'ip6tables'. It
  48. is also possible to let Suricata check both kinds of traffic.
  49. There is also a way to use iptables with multiple networks (and interface
  50. cards). Example:
  51. sudo iptables -I FORWARD -i eth0 -o eth1 -j NFQUEUE
  52. sudo iptables -I FORWARD -i eth1 -o eth0 -j NFQUEUE
  53. The options -i (input) -o (output) can be combined with all previous mentioned
  54. options
  55. If you would stop Suricata and use internet, the traffic will not come through.
  56. To make internet work correctly, you have to erase all iptable rules.
  57. To erase all iptable rules, enter:
  58. sudo iptables -F