IPtables installation and configuration: Try this approach

Hi Guys, whoever is having issue with iptables installation and configuration task, please try this approach.I have had success with it.I am new to linux and I thought to share with the community. Anyway, this approach has worked for me.

1)install iptables in all three apps( stapp01, stapp02, stapp03)

sudo yum install –y iptables-services

systemctl enable iptables

systemctl enable ip6tables

systemctl start iptables

systemctl start ip6tables

sudo iptables -A INPUT -p tcp --destination-port (in question) -s -j ACCEPT
sudo iptables -A INPUT -p tcp --destination-port (in question) -j DROP

  1. service iptables save

Please, let me know your thoughts.Thanks.

1 Like

@nidhincn Hi, can we just do the accept command part as it will ultimately reject for other incoming connections on the port specified?
Why did you do the DROP part please let me know , im bit confused.

Sorry for getting back to you late.The question specifically asks for blocking the port in question, so I have explicitly used the DROP command here.As, i mentioned already, I am new to Linux and still learning the things.However, this approach has worked for me.Thanks.

1 Like