In Linux, we use the iptabes to manage different firewall rules.
1. List all the rules.
- iptables -L
2. Allow incoming tcp port 8888 only from 123.123.123.123.
- iptables -A INPUT -i eth0 -p tcp –dport 8888 -s 123.123.123.123 -j ACCEPT -m comment –comment “001 Testing rule comment”
4. To delete the rule you can use the following command.
- iptables -D INPUT -i eth0 -p tcp –dport 8888 -s 123.123.123.123 -j ACCEPT -m comment –comment “001 Testing rule comment”
5. Alternatively, you can first list the firewall rules in line numbers.
- iptables -L INPUT –line-numbers
6. And then delete a specific rule by providing the line number, in my case which is 11.
- iptables -D INPUT 11
7. Finally, make sure you have save the changes to the server iptables confif file. (Thanks Philip =D)
For Ubuntu Lucid:
- iptables-save > /etc/iptables.firewall.rules
For CentOS/Fedora
- iptables-save > /etc/sysconfig/iptables
Done =)
Remember to run iptable save otherwise all will be gone after reboot!
LikeLike
O yes~ let me update the post~
Thx~ =)
LikeLike
No problem. This is a critical part in linux admin exam. 😉
LikeLike
haha~ you now look like more a server admin more than a developer~ XD
LikeLike
yes, I’m… I’m script developer at most now…
LikeLike