Junxiao Shi | 2feae5b | 2014-06-19 02:40:22 -0600 | [diff] [blame^] | 1 | #!/bin/bash |
| 2 | DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )" |
| 3 | source ../multi-host.conf |
| 4 | |
| 5 | # linkfail.sh fail|recover end1 end2 |
| 6 | |
| 7 | ACT=$1 |
| 8 | END1=$2 |
| 9 | END2=$3 |
| 10 | CTRLVAR1='CTRL_'${END1:0:1} |
| 11 | CTRLVAR2='CTRL_'${END2:0:1} |
| 12 | IP4VAR1='IP4_'$END1 |
| 13 | IP4VAR2='IP4_'$END2 |
| 14 | |
| 15 | CMD='-D' |
| 16 | if [[ $ACT == 'fail' ]] |
| 17 | then |
| 18 | CMD='-I' |
| 19 | fi |
| 20 | |
| 21 | ssh ${!CTRLVAR1} "sudo iptables $CMD INPUT -s ${!IP4VAR2}/32 -p udp --dport 6363 -j DROP" |
| 22 | ssh ${!CTRLVAR2} "sudo iptables $CMD INPUT -s ${!IP4VAR1}/32 -p udp --dport 6363 -j DROP" |
| 23 | |