IPTables and Bashrc Aliases

Sun, Aug 30, 2009

Linux

We all know IPTables can be difficult. By adding the following lines to your ~/.bashrc you can simplify the tasks of blocking packets from a certian ip.

First your going to need to install IPTables:
Gentoo: emerge iptables   (Must be  Root to use/install iptables)
Ubuntu/Debian: sudo apt-get install iptables

Then edit your .bashrc file and add the following

alias blockedips="iptables -L"
alias blockip="iptables -I INPUT -j DROP -s "
alias unblockip="iptables -D INPUT -j DROP -s "

Reload your .bashrc by running source .bashrc and you should then be able to run the commands below

blockedips - Will Show all Blocked hosts
blockip IP-HERE - Will Block that ip
unblockip IP-HERE - Unblocks that ip

screenshot-rootredfire

, , , , , ,

This post was written by:

RCP - who has written 1 posts on Tuts4Tech.


Contact the author

This website uses IntenseDebate comments, but they are not currently loaded because either your browser doesn't support JavaScript, or they didn't load fast enough.

Leave a Reply