I'm new to opening up ports in CentOS. I need to open up tcp port 8080 and have installed/ran nmap to find it is not open already. I've been reading about the iptables command, I have v1.3.5 installed but I really don't know where to start with it regarding opening up this port.

I'd appreciate a code sample or at least a link to a guide to opening this port using iptables (or any other good method.)

Thank you.

link|improve this question

feedback

2 Answers

up vote 3 down vote accepted

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"
link|improve this answer
I performed the first statement you listed, saved it, and restarted the server. I can't seem to see the 8080 opened using nmap? – user1062058 Dec 17 '11 at 2:01
feedback

See the CentOS docs: http://www.centos.org/docs/5/html/5.2/Deployment_Guide/ch-iptables.html and the wiki: http://wiki.centos.org/HowTos/Network/IPTables

link|improve this answer
Hi, the wiki seemed to clear things up more than the docs. Would this be a good command ? iptables -A INPUT -p tcp --dport 8080 -j ACCEPT – user1062058 Dec 16 '11 at 23:09
Yes, this is the command. – Stone Dec 17 '11 at 7:24
feedback

Your Answer

 
or
required, but never shown

Not the answer you're looking for? Browse other questions tagged or ask your own question.