I'd like to write a bash/shell script that "turns off" the machine's ability to communicate over it's network card, effectively shutting down all networking. From the command line:
# To turn all networking off
sh networking.sh OFF
# Then to turn it back on
sh networking.sh ON
The only way I can think of doing this would be at the port-level via IPTABLES
, but having never experimented with that before, I'm not sure if I'm even heading down the right avenue or if I'm way off base. Thanks in advance.
for n in ifconfig -a | grep eth | cut -d ' ' -f 1
; do bringing down echo $n ; ifconfig $a down ; done (ifconfig -a showing all devices. Grep filters down to lines containing eth. Cut first field (separated by spaces). And for to loop through all the answers. Kludgy, but works.IPTABLES
. Thanks again!trickled
(trickle daemon) with up/download bandwidths set to0
. My only question is: how do I restore the up/download bandwidths when I want to bring the network back "up"?!?