+TEST=`ping -c 2 $5 2>/dev/null | tail -2 | head -1 | cut -d"," -f2`;
+
+if [ "$TEST" == " 2 packets received" ]; then
+ echo "$5 gateway" >> /tmp/hosts
+else
+ FIRE=`nslookup ping.ipfire.org | tail -2 | head -1 | cut -d" " -f2`;
+ echo "$FIRE gateway" >> /tmp/hosts
+fi
+
+mv /tmp/hosts /etc/hosts