Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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.

share|improve this question
"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
up vote 2 down vote accepted

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.

share|improve this answer
thanks for the suggestions, that will help – Richard Oct 27 '13 at 13:35

Your Answer


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.