Opening up port 8080 in CentOS

Solution 1:

I always like to add a comment and limit scope in my firewall rules.

If I was opening up tcp port 8080 from everywhere (no scope limiting needed) for Tomcat I would run the following command

iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -j ACCEPT -m comment --comment "Tomcat Server port"

Then make sure to save your running iptables config so that it goes into effect after the next restart

service iptables save 

Note: you'll need to have the comment module installed for that part to work, probably a good chance that it is if you are running Centos 5 or 6

P.S.

If you want to limit scope you can use the -s flag. Here is an example on how to limit traffic to 8080 from the 192.168.1 subnet

iptables -A INPUT -m state --state NEW -m tcp -p tcp --dport 8080 -s 192.168.1.0/24 -j ACCEPT -m comment --comment "Tomcat Server port"

Solution 2:

For CentOS 7:

firewall-cmd --permanent --add-port=8080/tcp
firewall-cmd --reload

See the documentation for FirewallD.