Closing / Blocking Ports with IPTABLES
Hello, I'm new on this forum. And I'm pretty new to Linux as well.
I was hoping that someone could either show me or point me in the general direction with what i'm trying to get accomplished.
I'd like to block all ports for TCP traffic with the exception of a few ports.
Lets say the ports I needed open are 40001-40003, 40010, 40020-40030 and 8080.
I think I understand how to allow traffic to these ports for instance:
This would allow tcp traffic on ports 40020 through 40030
iptables -I INPUT 1 -p tcp --dport 40020:40030 -j ACCEPT
However, is there an easy way to block all the other ports on the server? Or what format would I use to block traffic on all the other ports besides the ones I wanted open?
Thanks in advance...