{"id":1628,"date":"2015-01-22T16:35:12","date_gmt":"2015-01-22T16:35:12","guid":{"rendered":"https:\/\/qbytes.cloud\/?p=1628"},"modified":"2015-01-22T16:35:12","modified_gmt":"2015-01-22T16:35:12","slug":"cloud-server-iptables-rejects-port-80","status":"publish","type":"post","link":"https:\/\/www.qbytes.cloud\/index.php\/2015\/01\/22\/cloud-server-iptables-rejects-port-80\/","title":{"rendered":"Cloud Server Iptables rejects port 80 CentOS 6.5"},"content":{"rendered":"<p>I have just intalled apache on a fresh CentOS 6.5 installation. I entered the ip address in the browser address bar, and it failed to connect. I then turned off iptables, and refeshed, and this time I could connect.<\/p>\n<p>So clearly iptables is blocking the http (port 80) traffic. So I looked at the iptables rules:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# Firewall configuration written by system-config-firewall\n# Manual customization of this file is not recommended.\n*filter\n:INPUT ACCEPT &#x5B;0:0]\n:FORWARD ACCEPT &#x5B;0:0]\n:OUTPUT ACCEPT &#x5B;0:0]\n-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n-A INPUT -p icmp -j ACCEPT\n-A INPUT -i lo -j ACCEPT\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n-A INPUT -j REJECT --reject-with icmp-host-prohibited\n-A FORWARD -j REJECT --reject-with icmp-host-prohibited\nCOMMIT\n\n<\/pre>\n<p>It seems confusing as there is a &#8220;accept all&#8221; rule. I typed this &#8211; it explains the devices as well where acept all is on the lo interface. So all eth connections are dropped.:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# iptables -L -v\nChain INPUT (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination         \n   11   764 ACCEPT     all  --  any    any     anywhere             anywhere            state RELATED,ESTABLISHED \n    0     0 ACCEPT     icmp --  any    any     anywhere             anywhere            \n    0     0 ACCEPT     all  --  lo     any     anywhere             anywhere            \n    0     0 ACCEPT     tcp  --  any    any     anywhere             anywhere            state NEW tcp dpt:ssh \n    0     0 REJECT     all  --  any    any     anywhere             anywhere            reject-with icmp-host-prohibited \n\nChain FORWARD (policy ACCEPT 0 packets, 0 bytes)\n pkts bytes target     prot opt in     out     source               destination         \n    0     0 REJECT     all  --  any    any     anywhere             anywhere            reject-with icmp-host-prohibited \n\nChain OUTPUT (policy ACCEPT 6 packets, 824 bytes)\n pkts bytes target     prot opt in     out     source               destination         \n\n<\/pre>\n<p>Edit iptables to add the rule:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n\n# nano \/etc\/sysconfig\/iptables\n# Firewall configuration written by system-config-firewall\n# Manual customization of this file is not recommended.\n*filter\n:INPUT ACCEPT &#x5B;0:0]\n:FORWARD ACCEPT &#x5B;0:0]\n:OUTPUT ACCEPT &#x5B;0:0]\n-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n-A INPUT -p icmp -j ACCEPT\n-A INPUT -i lo -j ACCEPT\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n-A INPUT -j REJECT --reject-with icmp-host-prohibited\n-A FORWARD -j REJECT --reject-with icmp-host-prohibited\n\n<\/pre>\n<p>Copy the ssh port 22 line and add it right under it, then change the port to 80. This is what it should look like:<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# Firewall configuration written by system-config-firewall\n# Manual customization of this file is not recommended.\n*filter\n:INPUT ACCEPT &#x5B;0:0]\n:FORWARD ACCEPT &#x5B;0:0]\n:OUTPUT ACCEPT &#x5B;0:0]\n-A INPUT -m state --state ESTABLISHED,RELATED -j ACCEPT\n-A INPUT -p icmp -j ACCEPT\n-A INPUT -i lo -j ACCEPT\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 22 -j ACCEPT\n-A INPUT -m state --state NEW -m tcp -p tcp --dport 80 -j ACCEPT\n-A INPUT -j REJECT --reject-with icmp-host-prohibited\n-A FORWARD -j REJECT --reject-with icmp-host-prohibited\n<\/pre>\n<p>Restart iptables<\/p>\n<pre class=\"brush: bash; title: ; notranslate\" title=\"\">\n# service iptables save\nservice iptables restart\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>I have just intalled apache on a fresh CentOS 6.5 installation. I entered the ip address in the browser address bar, and it failed to connect. I then turned off iptables, and refeshed, and this time I could connect. So clearly iptables is blocking the http (port 80) traffic. So I looked at the iptables &#8230; <a title=\"Cloud Server Iptables rejects port 80 CentOS 6.5\" class=\"read-more\" href=\"https:\/\/www.qbytes.cloud\/index.php\/2015\/01\/22\/cloud-server-iptables-rejects-port-80\/\" aria-label=\"Read more about Cloud Server Iptables rejects port 80 CentOS 6.5\">Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[17,52],"tags":[],"class_list":["post-1628","post","type-post","status-publish","format-standard","hentry","category-cloud","category-iptables"],"_links":{"self":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/1628","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/comments?post=1628"}],"version-history":[{"count":0,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/posts\/1628\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/media?parent=1628"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/categories?post=1628"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.qbytes.cloud\/index.php\/wp-json\/wp\/v2\/tags?post=1628"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}