Let me clarify: I have an iMac wich is wireless connected to the router from the ISP.

The CentOS computer is connected to the iMac with a cable and internet sharing is turned on. Installed nginx on the CentOS but I can not get access to it from my iMac.

If I run curl I get connection refused

On my CentOS wget is working, because I get the index page from the iMac server running Apache.

Is CentOS running a firewall?


for the moment I turned off iptables and I can connect, but what I would like to ask now is how to set a rule to allow incoming requests.

  • "Is Centos running a firewall?" iptables -L will give you a clue about this.
    – goldilocks
    Oct 27 '13 at 12:21
  • @goldilocks, thanks I edited my question, I hope for an answer so I can close this question
    – Richard
    Oct 27 '13 at 12:47

I would like to ask now is how to set a rule to allow incoming requests.

The easiest way to do that is probably to edit the iptables rules. On CentOS they are probably in /etc/sysconfig/iptables. Make a backup copy of that before you start -- just cp iptables iptables.bk. You will need superuser permissions to access the file, so su root before you do all this.

The file hopefully has comments in it explaining the purpose of various rules; you might look through those to see if there is a line you can uncomment to allow for an HTTP server. If not, add at the top:

-A INPUT -p tcp --dport 80 -m state --state NEW -j ACCEPT

Hopefully that's enough (if you've used the net at all otherwise with the firewall up, it should be), presuming you are using the normal HTTP port (80).

Now you can restart iptables. If your CentOS uses systemd, systemctl restart iptables, otherwise service iptables restart.

If there's a problem try iptables-restore < /etc/sysconfig/iptables, that will give you a more informative error.


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.