You better attach a script of this size. At least use code tags to make it more readable.
What are the double quotation marks for: D=""$(( $RANDOM ($NIO) ))""
Also, I think you can replace your 255 iptables commands with a loop:
Code:
for addr in {2..249}
do
D=$(( $RANDOM ($NIO) ))
iptables -t nat -A POSTROUTING -s 10.8.0.$addr -j SNAT --to-source ${IP[$D]}
done
(there should be a percent sign in the D=.... command, but Linuxquestions eats it)
But most importantly - you say there is some error. If you don't say what the error is, it's not possible to help you.