Not able to open a port in cent os 7

General support questions
Post Reply
abhishes
Posts: 14
Joined: 2009/07/18 20:25:36

Not able to open a port in cent os 7

Post by abhishes » 2014/07/13 08:15:05

I am trying to open the ports 2888 and 3888 in my newly installed centos

I have read this article

http://wiki.centos.org/HowTos/Network/IPTables

I I have issued the command

sudo iptables -A INPUT -p tcp -m tcp --dport 2888 -j ACCEPT
sudo iptables -A INPUT -p tcp -m tcp --dport 3888 -j ACCEPT

The wiki article above tells me to do a `/sbin/service iptables save`

However when I run the save command I get an error

the service command supports only basic LSB actions (start, stop, restart, try-restart, reload, force-reload, status). For other actions, please try to use systemctl.

what am I doing wrong? based on the documentation I understand that the sudo iptables -A command will not survive the reboot unless I do a save first. but I am not able to do a save on iptables.

I googled on the subjet and I found people saying that I should look for file /etc/init.d/iptables. but in my case this file does not exist.

markkuk
Posts: 739
Joined: 2007/09/07 10:56:28
Location: Finland

Re: Not able to open a port in cent os 7

Post by markkuk » 2014/07/13 09:25:34

abhishes wrote: what am I doing wrong?
You're following documentation written for CentOS 6 or earlier. CentOS 7 has switched to systemd, which makes everything you know about managing services in Unix/Linux systems obsolete. Additionally, the firewall in CentOS 7 is managed dynamically by firewalld by default. Read the RHEL 7 Security Guide for instructions on opening ports in the firewall.

abhishes
Posts: 14
Joined: 2009/07/18 20:25:36

Re: Not able to open a port in cent os 7

Post by abhishes » 2014/07/13 17:14:07

I went through the article but its a little too much and does not give the exact steps.

Can you give me the exact steps to open port 2888 and 3888 on cent os 7?

abhishes
Posts: 14
Joined: 2009/07/18 20:25:36

Re: Not able to open a port in cent os 7

Post by abhishes » 2014/07/14 04:14:07

I found this

firewall-cmd --zone=public --add-port=2888/tcp

but it goes away if I reboot the machine.

Is there a more permanent way.

OR

could you tell me how to disable the firewall altogether.

burritohead
Posts: 1
Joined: 2014/07/14 04:48:55

Re: Not able to open a port in cent os 7

Post by burritohead » 2014/07/14 04:50:53

you need to add --permanent

firewall-cmd --zone=public --permanent --add-port=2888/tcp

drk
Posts: 405
Joined: 2014/01/30 20:38:28

Re: Not able to open a port in cent os 7

Post by drk » 2014/07/14 05:08:41

abhishes wrote:Is there a more permanent way.
The man page says for firewall-cmd says:
Permanent Options
--permanent
The permanent option --permanent can be used to set options
permanently. These changes are not effective immediately, only
after service restart/reload or system reboot. Without the
--permanent option, a change will only be part of the runtime
configuration. The --permanent option can not be used with all
options.

If you want to make a change in runtime and permanent
configuration, use the same call with and without the--permanent
option.

The --permanent option can be optionally added to all options
further down where it is supported.

abhishes
Posts: 14
Joined: 2009/07/18 20:25:36

Re: Not able to open a port in cent os 7

Post by abhishes » 2014/07/17 15:25:23

I also found another way

http://serverfault.com/questions/470287 ... -fedora-18

I think this is sure shot way of getting rid of firewall in a centos 7 compatible way.

Post Reply

Return to “CentOS 7 - General Support”