Technical Tip: How to test and verify if the DoS policy is working using 'hping3' from Linux and Powershell from Windows
| Description | This article describes how to test if the DoS policy is working by using 'hping3' on Linux and PowerShell on Windows. |
| Scope | FortiOS, DoS Policies. |
| Solution | The easiest way to test if a DoS policy is successfully blocking traffic is by using a utility to generate traffic that meets the conditions of the DoS policy.
  In the Linux example below, the 'udp_flood' sensor will be tested:
  This can be done on Linux by using a utility called 'hping3'. This is built into some Linux distros; if not already installed, it is possible to grab it by using the distro's package manager. The command would be as follows: sudo hping3 --udp -p 3000 x.x.x.x --flood -c 3000 '--udp' specifies UDP as the type, '-p' specifies the port, 'x.x.x.x' is the destination IP (this should be the firewall's IP), '--flood' is the speed at which packets are sent, and '-c' is how many packets are sent (might be ignored with --flood).
Under Log & Report -> Security Events -> Anomaly, it is possible to see that the traffic is blocked:
On Windows, there is no binary of 'hping3' available. Other TCP or UDP ping utilities (like PsPing) do not generate enough traffic to be picked up by the DoS policy, so a PowerShell script can be used instead. For this example, the 'tcp_syn_flood' sensor will be tested.
  The PowerShell script used to generate this traffic is as follows:
1..5000 | ForEach-Object {
Replace 'x.x.x.x' with the firewall IP, and 'yyy' with the port that should be tested. It does not matter what port is used in this context. Simply copy and paste the commands into PowerShell and run them. There will be the following output in PowerShell when the script is working correctly:
  Here is the traffic getting blocked in the firewall:
|







