iptables - Unable to open some port

Support for security such as Firewalls and securing linux
Post Reply
Fred_Lux
Posts: 2
Joined: 2017/04/26 09:56:46

iptables - Unable to open some port

Post by Fred_Lux » 2017/04/26 19:29:12

Hi everyone,
I'm new with CentOS and iptables and I've difficulties to open some port.
To open port 8443 and 8447 (Plesk admin and plesk autoinstaller) I've use the following command:

Code: Select all

root@plesk ~ # iptables -A INPUT -p tcp -m tcp --dport 8443 -j ACCEPT


Then I've tried to open 80 and 443. So I've use:

Code: Select all

root@plesk ~ # iptables -A INPUT -p tcp -m tcp --dport 80-j ACCEPT
But no result, the port 80 is still close.

What I'm doing wrong?

PS: FirewallD is not running
Version: CentOS Linux release 7.3.1611 (Core)

User avatar
TrevorH
Site Admin
Posts: 33216
Joined: 2009/09/24 10:40:56
Location: Brighton, UK

Re: iptables - Unable to open some port

Post by TrevorH » 2017/04/26 21:35:29

OK, so if firewalld is not running then presumably you have iptables-services installed and that restores the rules for you on restart. It's very likely that the initial set of rules ended with a catch-all one that does a -j REJECT and all your iptables -A commands have done is place the new rules after that reject rule and so they are never reached.

Run iptables=-save and look at your running rules. If there's a -j REJECT halfway down then save the rules, edit /etc/sysconfig/iptables and move the reject rule to the end then restart iptables.
The future appears to be RHEL or Debian. I think I'm going Debian.
Info for USB installs on http://wiki.centos.org/HowTos/InstallFromUSBkey
CentOS 5 and 6 are deadest, do not use them.
Use the FAQ Luke

hunter86_bg
Posts: 2019
Joined: 2015/02/17 15:14:33
Location: Bulgaria
Contact:

Re: iptables - Unable to open some port

Post by hunter86_bg » 2017/04/28 07:28:53

Using "-A INPUT" will add the rule to the bottom - just below the reject/drop rules and will never work.
Try the "-I 3 INPUT" which will insert it as 3-rd rule.

Edit: Check the second rule for syntax error (80-j)

Fred_Lux
Posts: 2
Joined: 2017/04/26 09:56:46

Re: iptables - Unable to open some port

Post by Fred_Lux » 2017/04/28 10:48:40

Sorry I've find why the port 80 and 443 won't open. Nginx was configured to work as reverse proxy. So my iptables config was fine.

Thank you for your advice.

Post Reply