Type "firewall" into the search bar and then click on "windows defender firewall".
Now click on "advanced settings".
Click on either "Imbound Rules" or "Outbound Rules" depending on which one you need.
Then click on "new rule".
Make sure you have the "port" selection selected.
Select "TCP" or "UDP". If you need to allow both, you will have to make another rule (one for TCP and the other for UDP).
Then type in what port you want to allow through. I've typed in the fivem default port.
You can allow more than one port though by using commas and dashes.
For example, "30120, 40120" will allow ports 30120 and 40120.
If you did "30120 - 30122" that would allow ports 30120, 30121 and 30122 through the firewall.
Click on the option that most applies to you here. If you want to fully open the port, select the "Allow the connection" option.
Here, select what applies to you. Normally, you would leave these all checked.
Here, name the rule something you can remember as I have done below.
You have now allowed the port(s) through your firewall!