Need help with opening/closing ports with firewalld

We have a backup management application UI hosted on Nautilus’s backup server in Stratos DC.
That backup management application code is deployed under Apache on the backup server itself,
and Nginx is running as a reverse proxy on the same server. Apache and Nginx ports are 3004 and 8095,
respectively. We have iptables firewall installed on this server. Make the appropriate changes
to fulfill the requirements mentioned below:

We want to open all incoming connections to Nginx’s port and block all incoming connections
to Apache’s port. Also make sure rules are permanent.

Terminal output:
[[email protected] ~]# firewall-cmd --permanent --add-port=8095/tcp
[[email protected] ~]# firewall-cmd --permanent --add-port=8095/udp
[[email protected] ~]# firewall-cmd --remove-port=3004/tcp --permanent
Warning: NOT_ENABLED: 3004:tcp
[[email protected] ~]# firewall-cmd --remove-port=3004/udp --permanent
Warning: NOT_ENABLED: 3004:udp
[[email protected] ~]# firewall-cmd --reload
[[email protected] ~]#

Task Error:

  • “Either firewall rule was not added for Nginx port ‘8095’ or rule was not permanently added on Backup server”

Your help would be much appreciated

We have iptables firewall installed on this server

The task want us to use iptables command instead of firewall-cmd. Try these

[[email protected] ~]# systemctl status iptables
[[email protected] ~]# systemctl start iptables
[[email protected] ~]# iptables -A INPUT -p tcp --dport 8095 -m conntrack --ctstate NEW,ESTABLISHED -j ACCEPT
 iptables -A INPUT -p tcp --dport 3004 -m conntrack --ctstate NEW -j REJECT
[[email protected] ~]# iptables -R INPUT 5 -p icmp -j REJECT
[[email protected] ~]#service iptables save
[email protected]_host ~$ telnet stbkp01 3004
[email protected]_host ~$ telnet stbkp01 8095

Don’t forget to change the port numbers according to the task.
And Please refer to the link to request a review for assistance.

Thanks @waiyanpyaesone06 !
Interesting to ask to use iptables instead of firewalld on cento 7.
I know the assignement mentions iptables somewhere but maybe it can be stated clearly that the task should be completed using iptables.
Do you suggest using reviews instead of posting this questions on the community board? I figured posting on the board would allow the whole community to help instead of putting the whole load on the admins.


Hello @jcakakpo

Do you suggest using reviews instead of posting this questions on the community board?

I would suggest you to do both. Using review could help you get the answer a lot quicker and you would get a chance to see other possible solutions.
As you suggested above, posting here could aware the community about the task and we would also get a chance to explain you to understand the task better.
So, therefore use review button to request assistance from other fellow engineers on KKE and post your query here also.


1 Like

Thanks waiyanpyaesone06 !

1 Like

Is there a reason why the lab uses iptables vs firewalld? Isn’t iptables deprecated?