V
V
Vlad2014-06-11 11:15:53
linux
Vlad, 2014-06-11 11:15:53

Configuring IPTABLES on CentOS 6.* to Access Certain Ports

Hello.
1) There is a certain server whose task is to give content (in our case, pictures) on request through port 80 (nginx is configured) from everyone who wants it.
2) On the same server there is a Gearman Job Server, whose task is to accept jobs through port 4730 from itself (localhost) and from another external server.
In this regard, the question arises, how to configure IPTABLES so that this server can accept requests on port 80 from everyone who requires it, and only from one (or two) external ip addresses and itself on port 4730. For I have a strong feeling that if I start doing it according to the manuals, without experience, I will close access to myself for sure.
I don’t know much about Linux, so you can advise an intuitive firewall that can be configured more or less quickly for these needs, or you can advise suitable material for study. The naked article on iptables on the wiki blew my mind.
Thank you.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
A
Andrey Burov, 2014-06-11
@DaFive

iptables -A input -s eth0 -s xxx.xxx.xxx.xxx/32 -p tcp -m tcp --dport 4730 -j ACCEPT
iptables -A input -s eth0 -p tcp -m tcp --dport 4730 -j DROP

xxx.xxx.xxx.xxx - This is your other external server.
eth0 is the name of the network card.

R
rekby, 2014-06-27
@rekby

If it is possible to reboot the server (i.e. it is possible and it does not bring a lot of inconvenience):
1. iptables -I INPUT -p tcp --dport 22 -j ACCEPT (this is so that incoming packets on ssh are always accepted)
2. And then experiment without removing the first rule.
3. If, nevertheless, access via ssh is closed - reboot the server and continue
. At checkpoints, you can do:
And then to return to the saved state:
iptables-restore < file

L
Laurens Stroten, 2015-04-21
@megallodon

hello,
how to check the firewall on the centos server, what commands to find out if it blocked access to the site for search engine bots,
I would like to know if it is possible that the firewall on the server could block access to sites, there are no more transitions from search engines to the site,
maybe you know what can happen on the server another firewall to prevent search engine bots from accessing the site?

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question