How to close all the ports excluding the basic and necessary ones?

Hello everyone, I wanted to ask you how to close all ports accepting only requests for dns, http/s, smtp. I would also like to know how to block unsolicited packets. Well if anyone can help me very grateful in advance. Best regards.

Default firewall filter is pretty OK.

It allows most of connections to router from LAN and next to none from WAN. You have to explicitly allow some connections from WAN (probably you want to set up NAT rules). If you don’t want to allow much connectivity from LAN, then you have to change the firewall for chain=input.
Note that if someone tries some intensive port scanning or you become victim of DDOS attack, then router’s CPU will have quite some work to do with blocking unsolicited packets … if the scale of DDOS attack is large enough, then router may crash as well …

It allows all connections from LAN to WAN. If you want to restrict that, then you have to create some firewall rules to only allow selected connections and drop the rest.

Hello, thank you very much for the answer. I was looking in the forum and with different posts I was able to set up this closing the ports and so on.
I have another question. My ISP’s cable modem is in bridge mode. How can I make voip communication secure? If you can help me with rules set up by you I would be very grateful.
Best regards.