From 0d23cf157a7920a899cae6a346f734f7474e13be Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jonas=20Bone=CC=81r?= Date: Fri, 25 Mar 2011 16:09:44 +0100 Subject: [PATCH] added script to simulate network failure scenarios and restore original settings --- scripts/ip-mod.sh | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) create mode 100755 scripts/ip-mod.sh diff --git a/scripts/ip-mod.sh b/scripts/ip-mod.sh new file mode 100755 index 0000000000..e9b509ae59 --- /dev/null +++ b/scripts/ip-mod.sh @@ -0,0 +1,31 @@ +#!/bin/sh + +# flush rules +ipfw del pipe 1 +ipfw del pipe 2 +ipfw -q -f flush +ipfw -q -f pipe flush + +if [ "$1" == "" ]; then + echo "Options: ip-mod.sh slow" + echo " ip-mod.sh block" + echo " ip-mod.sh reset" + echo " ip-mod.sh restore" + exit +elif [ "$1" == "restore" ]; then + echo "restoring normal network" + exit +elif [ "$1" == "slow" ]; then + # simulate slow connection + echo "enabling slow connection" + ipfw add pipe 1 ip from any to any + ipfw add pipe 2 ip from any to any + ipfw pipe 1 config bw 60KByte/s delay 350ms + ipfw pipe 2 config bw 60KByte/s delay 350ms +elif [ "$1" == "block" ]; then + echo "enabling blocked connections" + ipfw add 1 deny tcp from any to any 1024-65535 +elif [ "$1" == "reset" ]; then + echo "enabling reset connections" + ipfw add 1 reset tcp from any to any 1024-65535 +fi