Search code examples
iptables

Linux server A iptables INPUT policy is set ACCEPT,server B disable firewall, but I can't detection A's httpd port from server B


Linux server A iptables INPUT policy is set ACCEPT,server B disable firewall, but I can't detection A's httpd port from server B.

# server A
# Generated by iptables-save v1.4.7 on Fri Oct 16 14:29:37 2015
*filter
:INPUT ACCEPT [0:0]   # <--see here
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [151:126429]
-A INPUT -m state --state RELATED,ESTABLISHED -j ACCEPT
-A INPUT -p icmp -j ACCEPT
-A INPUT -i lo -j ACCEPT
-A INPUT -p tcp -m state --state NEW -m tcp --dport 22 -j ACCEPT
-A INPUT -j REJECT --reject-with icmp-host-prohibited
-A FORWARD -j REJECT --reject-with icmp-host-prohibited
COMMIT
# Completed on Fri Oct 16 14:29:37 2015

Solution

  • There's an ACCEPT target for RELATED, ESTABLISHED connections only. You should add a rule for port 80/443/whatever_port_used_by_httpd with (assuming port 80):

    # iptables -I INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT
    

    An useful thing is to add a LOGnDROP (or LOGnREJECT here) instead of simply DROP (or REJECT) during troubleshooting.