Iptables Task - application security


Just wanted to understand what did I missed to configure? Any assistance to help me understand is much appreciated.

Task: We want to open all incoming connections to Nginx’s port and want to block all incoming connections to Apache’s port. Also make sure rules are permanent. Apache and Nginx ports are 8085 and 8094 respectively.

i think reason is iptables in disabled mode?

Thanks @player001 for the reply, but the issue was not that.

I figured out the issue which was that I used “–append” in the iptables rule which actually adds the rule in the end. I never noticed that the before i appended the rule, it was reject all. :slightly_smiling_face:

Just that we need to be careful in checking the current rules before applying the new rules.

I haven’t noticed thanks to inform me.

but you just did append that means added in the last line of chain. Even you added in first and last, rules will works. I think append options is also correct.

I think disable option is matter here. @Inderpreet can you please clear this issue. It will clear my doubts too. tasks failed reason is append option or service disable option? kindly brief more if possible.


Hi All,

Please check once, i have completed this task successfully but it is showing failed state.

according to screen shot accept and reject scenario is fine but how you did permanent?

share screen shot of commands how did you configured this iptables.

@player001 used below command to make rules permanent:
sudo systemctl enable iptables

i have completed this task before which got completed successfuly with the same commands.

sudo systemctl enable iptables is for start the service in next boot up automatically that’s not the process to make permanent.
iptables save something like command to make permanent.

It didn’t work for me as well. Please see attached screenshots.

Below image shows that connection from jump_host is being blocked for 8086 while it is wokring for 8092

Below image shows that iptable rules before. then i exited from ssh session. and then i sshed once again and listed the rules. both the times rules were same.

Is there any way by which i can take the same task once agian?

@Inderpreet any idea why this happened ?

@kp3642 I think you missed to add the rule as permanent.