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 have a new server, and am not that sure about iptables. I've tried opening ports (25565, as seen below) but still can't connect. iptables -L says the following;

Chain INPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     all  --  anywhere             anywhere            state RELATED,ESTABLISHED 
ACCEPT     icmp --  anywhere             anywhere            
ACCEPT     all  --  anywhere             anywhere            
ACCEPT     tcp  --  anywhere             anywhere            state NEW tcp dpt:ssh 
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         
REJECT     all  --  anywhere             anywhere            reject-with icmp-host-prohibited 

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
ACCEPT     tcp  --  anywhere             anywhere            tcp dpt:25565 

I think it's something to do with reject-with icmp-host-prohibited but I don't really know what that means.

Turning off iptables allows access so it's not the service running that is the problem.

Thanks in advance!

share|improve this question
    
Are you doing this local or over ssh ? [If you are a newbie with iptables adding removing rules remotely in IPtables could make you lose remote connection]. –  Alexandru-Florin Vintiloiu Jul 20 '13 at 22:56

2 Answers 2

The rule to accept should be added to the INPUT chain before the one that rejects everything.

The following should work:

iptables -I INPUT 4 -p tcp --dport 25565 -j ACCEPT

If it worked, then clear your OUTPUT chain and save your iptables settings:

iptables -F OUTPUT
/etc/init.d/iptables save
share|improve this answer
    
Rule #3 on INPUT is already accepting anything. Could it bethat he needs port forwarding in the router? –  ott-- Jul 20 '13 at 21:33
    
"Turning off iptables allows access so it's not the service running that is the problem.", so it can not be a port forwarding problem. –  Brigo Jul 20 '13 at 21:49

it should be:

iptables -I INPUT 4 -p tcp --dport 25565 --syn -m state --state NEW -j ACCEPT
share|improve this answer
    
That --syn is redundant, but the rule is otherwise correct. –  Jonathan Swinney Jul 24 '13 at 19:01

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.