Install iptables with persistent rules on Linux

Devops Hands-on practice with KodeKloud Completed real world task ✨ ✨ Task: Install iptables with persistent rules and block incoming traffic to port 6000 for everyone except load balancer host ➡️ Install Iptables "sudo yum install iptables iptables-services -y" ➡️ Enable and start the iptables "sudo systemctl enable iptables" "sudo systemctl start iptables" ➡️ Rules wil be deleted after a reboot, Save the iptables rules to make persistent "sudo /usr/libexec/iptables/iptables.init save" ➡️ Check the existing rules and add the required rules as per the priority "sudo iptables -L INPUT -n --line-numbers" ➡️ If any rule to reject traffic from everyone is available add the Allow and block 6000 port rule with high priority than the reject rule If reject rule has 7 priority, Allow and block rules should be added before that i.e; 5 and 6 ➡️ Add the rule with priority 5 to allow traffic only from load balancer server "sudo iptables -I INPUT 5 -p tcp --dport 6000 -s load-balancer-host-name -j ACCEPT" ➡️ Add the rule with priority 6 to block everyone "sudo iptables -I INPUT 6 -p tcp --dport 6000 -j DROP" ➡️ Save the added Rules "sudo iptables-save | sudo tee/etc/sysconfig/iptables #Devops #Linux #DevopsEngineer #Learning #Kodekloud

To view or add a comment, sign in

Explore content categories