0

I have a CentOS 7 image on VM VirtualBox (bridged Ethernet with static IP) I was trying to set iptables filter table but I have the following problems:

Whatever I did to open Apache on port 80 doesn't work (instead if I stop iptables service I can load web pages without any problem). I found somewhere that a possible solution could be to write a rule to enable bridge. Is it true? Anyway I can't find any bridge configuration in the machine.

I deleted default rule for port 22 and now I can't even login from SSH, even if I think I restored it.

This is the iptables file:

*filter
:INPUT ACCEPT [0:0]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A INPUT -p tcp -m tcp --dport 10000 -j ACCEPT
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A INPUT -j ACCEPT
-A INPUT -p tcp -m tcp --sport 137:139 --dport 137:139 -j ACCEPT
-A INPUT -p tcp -m tcp -m multiport --ports 445 -j ACCEPT
-A INPUT -p tcp -m tcp --dport 22 -j ACCEPT
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
*mangle
:PREROUTING ACCEPT [48:5579]
:INPUT ACCEPT [47:5507]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [39:4446]
:POSTROUTING ACCEPT [54:7320]
COMMIT
*nat
:PREROUTING ACCEPT [23:1557]
:INPUT ACCEPT [0:0]
:OUTPUT ACCEPT [7:548]
:POSTROUTING ACCEPT [7:548]
COMMIT
  • If you've added the rule back for ssh have you restarted the iptables service? – slm Oct 11 '14 at 15:30
0

Here's the problem:

-A INPUT -j REJECT --reject-with icmp-host-prohibited
## More rules

iptables walk-through all the rules in order, it finds that you reject all INPUT packages first even if you accept them later on. Reorder your rules so the REJECT are to the very end, and your ACCEPTS are at the very top. Also, remove the duplicated entries. It should work then.

The fact that you can't access both 80 and 22 port is due this.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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