fritsp1989
Regular Contributor
A couple of months ago i decided it was time to get a script to wake up my web server whenever i tried to connect to it.
So i modified a script with a lot of help from other people, and my knowledge to writing scripts is almost none.
Now my webserver is waking up a lot and i can see where it is coming from but i dont know how to stop it.
The problem is in the script i specified 3 ports and seperated them like this 80|443|3389
Seeing the script this way i thought that it would only listen to port 80|443|3389, but is doesn't.
My webserver wakes up in the middle of the night and this is my log
Is there someone that can explain me a little bit why the script also wakes the server on 8080 and what does the port SEQ mean ?
And is there a possible way i can define in the script to drop these ?
So i modified a script with a lot of help from other people, and my knowledge to writing scripts is almost none.
Now my webserver is waking up a lot and i can see where it is coming from but i dont know how to stop it.
The problem is in the script i specified 3 ports and seperated them like this 80|443|3389
#!/bin/sh
INTERVAL=5
NUMP=3
OLD=""
TARGET=192.168.1.2
PORT=80|443|3389
IFACE=br0
MAC=
WOL=/usr/bin/ether-wake
LOGFILE="/var/log/ether-wake.log"
while sleep $INTERVAL;do
NEW=`dmesg | awk '/ACCEPT/ && /DST='"$TARGET"'/ && /DPT='"$PORT"'/ {print }' | tail -1`
SRC=`echo $NEW | awk -F'[=| ]' '{print $8}'`
DPORT=`echo $NEW | awk -F'[=| ]' '{print $27}'`
PROTO=`echo $NEW | awk -F'[=| ]' '{print $23}'`
if [ "$NEW" != "" -a "$NEW" != "$OLD" ]; then
if ! ping -qc $NUMP $TARGET >/dev/null; then
# echo "NOWAKE $TARGET was accessed by $SRC, port $DPORT, protocol $PROTO and is already alive at" `date`>> $LOGFILE
# else
echo "WAKE $TARGET requested by $SRC, port $DPORT, protocol $PROTO at" `date`>> $LOGFILE
$WOL -i $IFACE $MAC
sleep 5
fi
OLD=$NEW
fi
done
Seeing the script this way i thought that it would only listen to port 80|443|3389, but is doesn't.
My webserver wakes up in the middle of the night and this is my log
WAKE 192.168.1.2 requested by 82.214.61.43, port 3389, protocol TCP at Wed Dec 19 14:53:19 GMT 2012
WAKE 192.168.1.2 requested by 5.199.137.195, port 3389, protocol TCP at Wed Dec 19 16:44:03 GMT 2012
WAKE 192.168.1.2 requested by 94.242.237.51, port SEQ, protocol <1>SPT at Wed Dec 19 18:41:33 GMT 2012
WAKE 192.168.1.2 requested by 94.76.251.7, port 3389, protocol TCP at Wed Dec 19 20:34:53 GMT 2012
WAKE 192.168.1.2 requested by 63.246.152.68, port SEQ, protocol <1>SPT at Thu Dec 20 01:26:59 GMT 2012
WAKE 192.168.1.2 requested by 122.112.12.57, port SEQ, protocol <1>SPT at Thu Dec 20 02:28:12 GMT 2012
WAKE 192.168.1.2 requested by 173.220.25.170, port SEQ, protocol <1>SPT at Thu Dec 20 03:07:12 GMT 2012
WAKE 192.168.1.2 requested by 65.183.8.54, port SEQ, protocol <1>SPT at Thu Dec 20 04:54:53 GMT 2012
WAKE 192.168.1.2 requested by 199.87.232.180, port 8080, protocol TCP at Thu Dec 20 07:28:39 GMT 2012
Is there someone that can explain me a little bit why the script also wakes the server on 8080 and what does the port SEQ mean ?
And is there a possible way i can define in the script to drop these ?