i want to open port 80,5432 and 22 to all ip address.

i want to open port 27017 only to these ip addresses x.x.x.0/24

in all the cases i want both tcp and udp access.

can you please tell what the config should be in iptables for this setup to work? thanks

link|improve this question
"open port" is not really technically correct. Sometimes it does matter which part (you or the remote host) initiates a connection. This will result in different firewall rules. – vtest Sep 20 '10 at 22:18
feedback

1 Answer

Do a quick Google search for an iptables tutorial. On a Fedora system, your firewall rules are kept in /etc/system/iptables. You might want rules that look similar to:

-A INPUT -i eth0 -p 22 -j ACCEPT
-A INPUT -i eth0 -p 80 -j ACCEPT
-A INPUT -i eth0 -p 5432 -j ACCEPT
-A INPUT -i eth0 -p 27017 -s x.x.x.0/24 -j ACCEPT

Although, I would not recommend opening ports 22 and 5432 to the world. The SSH connections should be locked down to as few sources as possible, and even then you might want to consider additional restrictions. The database connections should be restricted to the web server and those machines that you use to manage the database.

link|improve this answer
feedback

Your Answer

 
or
required, but never shown

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