Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I installed Apache Tomcat-7.0.32 on Linux Mandriva and I want to make it accessible. for this I need to open ports in iptables.

I added the following rules-

iptables -A INPUT -p tcp -m tcp --dport 8081 --syn -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8010 --syn -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8444 --syn -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 8006 --syn -j ACCEPT

then save and restart iptables -

/etc/init.d/iptables save
/etc/init.d/iptables restart

verify, that ports is open -

netstat -tulpn | less

I am running command -

netstat-ntpl | grep java

and see -

enter image description here

When I disable the firewall, I see the start page of the server on request -

http://server_ip:8081/

When enable - server not accessible from outside.

In what may be the cause? I would be most grateful for the information!

Thank you!

share|improve this question

migrated from stackoverflow.com Oct 16 '12 at 10:02

This question came from our site for professional and enthusiast programmers.

add comment

2 Answers

up vote 0 down vote accepted

This issue is not related to Tomcat configuration. Make sure that you add accept iptables rules before reject rules

share|improve this answer
    
Thank you, Anton! –  ivanov-void Oct 16 '12 at 9:39
    
Whew! I added, as you said, and it worked! Thank you again! iptables -I INPUT -p tcp -m tcp --dport 8081 --syn -j ACCEPT iptables -I INPUT -p tcp -m tcp --dport 8010 --syn -j ACCEPT iptables -I INPUT -p tcp -m tcp --dport 8444 --syn -j ACCEPT iptables -I INPUT -p tcp -m tcp --dport 8006 --syn -j ACCEPT –  Alexey Oct 16 '12 at 10:07
add comment

Ports used by tomcat should be in tomcat configuration. However, in case of doubts, you may want to use lsof utility to find out details about what programs use what TCP or UDP ports, and local sockets.

lsof -Pni
lsof -Uni

To find out what exactly happens, and what programs are trying to access what ports, and/or are blocked by the firewall, you could also use tcpdump utility.

tcpdump -i eth0

You can grep outputs of these programs or use switches to filter what kind of information is to be displayed. What you do wrong may be, that you add your firewall rules at the end of configuration, while iptables configuration ( firewall packets processing ) comes from the top/beginning - so when you add ACCEPTs it probably makes sense to add it at the beginning of iptables configuration file rather than at the end.

This question probably should be moved to superuser.com

share|improve this answer
    
Thanks for the advice, Piotr Wadas! –  ivanov-void Oct 16 '12 at 9:39
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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