-1

I know how to add aliases to bashrc and run it.

For example:

$ sudo nano ~/.bashrc

and add line;

alias startmyservicescommand='/home/startmyservice.sh'

but, now i want to add "variables" to my command.

for example my command will be :

iptables -A INPUT -s IP-ADDRESS -j DROP

and i want use command as:

ip_ban IP-ADDRESS (ip_ban is my self alias and IP-ADDRESS is a variable)

How can i add this command to bashrc?

Thank you.

Benjamin
  • 2,073
  • 4
  • 18
  • 16

1 Answers1

-1

For ubuntu 14 this worked for me :

alias ipbanekle='_ipbanekle(){ iptables -A INPUT -s "$1" -j DROP; /etc/init.d/iptables-persistent save; /etc/init.d/iptables-persistent reload; }; _ipbanekle'

For 16 and higher;

alias ipbanekle='_ipbanekle(){ iptables -A INPUT -s "$1" -j DROP; netfilter-persistent save; netfilter-persistent reload; }; _ipbanekle'

And call:

ipbanekle ip.address

thats all. Thanks.

Benjamin
  • 2,073
  • 4
  • 18
  • 16