Quick how to for my personal records. iptables is an open source firewall (and it does a lot more) included with most linux distributions.
Steps to add new rule to existing configuration
- Check the list of rules and their corresponding sequence
sudo iptables -vL --line-numbers
- Add the new rule at the required location/sequence
sudo iptables -I INPUT LINE_NUMBER RULE
Example :
iptables -I INPUT 8 -s X.X.X.X/24 -p tcp -m state --state NEW -m tcp --dport 3128 -j ACCEPT
- Save the configuration
sudo serivce iptables save
Thx to Sijis for helping with the commands.