executing
iptables -F
is very dangerous if your default policy for one or all chains is DROP
I would like to use an alias in bashrc
like
alias iptables -F="echo \
'WARNING: due to the DROP default rule, flushing all rules would lock you out'"
but this does not work.
This should not work because of the space in your alias name.
You could call a custom function instead, in
.bash_aliases
:This will print the warning message if
iptables
argument is-F
.Otherwise, it will execute the normal
iptables
command, including all parameters you may have passed to it ($@
).command
will run the realiptables
command, preveting calling back your own function :