1 |
14f9c43f
|
Scott Ullrich
|
#!/bin/sh
|
2 |
|
|
|
3 |
|
|
# Update bogons file
|
4 |
|
|
# Part of the pfSense project
|
5 |
|
|
# www.pfsense.com
|
6 |
|
|
|
7 |
9c9b1833
|
Scott Ullrich
|
echo "rc.update_bogons.sh is starting up." | logger
|
8 |
|
|
|
9 |
fc1e7d9f
|
Chris Buechler
|
# Sleep for that time, unless an argument is specified.
|
10 |
9dbb93ba
|
Chris Buechler
|
|
11 |
5de28171
|
Scott Ullrich
|
if [ "$1" = "" ]; then
|
12 |
9dbb93ba
|
Chris Buechler
|
# Grab a random value
|
13 |
|
|
value=`od -A n -d -N2 /dev/random | awk '{ print $1 }'`
|
14 |
|
|
echo "rc.update_bogons.sh is sleeping for $value" | logger
|
15 |
|
|
sleep $value
|
16 |
fc1e7d9f
|
Chris Buechler
|
fi
|
17 |
38b65b80
|
Scott Ullrich
|
|
18 |
9c9b1833
|
Scott Ullrich
|
echo "rc.update_bogons.sh is beginning the update cycle." | logger
|
19 |
|
|
|
20 |
48e29ac9
|
sullrich
|
# Mount RW if needed
|
21 |
14f9c43f
|
Scott Ullrich
|
/etc/rc.conf_mount_rw
|
22 |
48e29ac9
|
sullrich
|
|
23 |
|
|
/usr/bin/fetch -q -o /tmp/bogons "http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt"
|
24 |
e59010af
|
Scott Ullrich
|
if [ ! -f /tmp/bogons ]; then
|
25 |
48e29ac9
|
sullrich
|
echo "Could not download http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt" | logger
|
26 |
b5158c60
|
Scott Ullrich
|
# Relaunch and sleep
|
27 |
|
|
sh /etc/rc.update_bogons.sh &
|
28 |
e59010af
|
Scott Ullrich
|
exit
|
29 |
|
|
fi
|
30 |
48e29ac9
|
sullrich
|
|
31 |
|
|
BOGON_MD5=`/usr/bin/fetch -q -o - "http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt.md5" | awk '{ print $4 }'`
|
32 |
|
|
ON_DISK_MD5=`md5 /tmp/bogons | awk '{ print $4 }'`
|
33 |
|
|
if [ "$BOGON_MD5" = "$ON_DISK_MD5" ]; then
|
34 |
|
|
egrep -v "^192.168.0.0/16|^172.16.0.0/12|^10.0.0.0/8" /tmp/bogons > /etc/bogons
|
35 |
|
|
/etc/rc.conf_mount_ro
|
36 |
|
|
RESULT=`/sbin/pfctl -t bogons -T replace -f /etc/bogons 2>&1`
|
37 |
|
|
rm /tmp/bogons
|
38 |
|
|
echo "Bogons file downloaded: $RESULT" | logger
|
39 |
|
|
else
|
40 |
|
|
echo "Could not download http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt.md5 (md5 mismatch)" | logger
|
41 |
|
|
# Relaunch and sleep
|
42 |
|
|
sh /etc/rc.update_bogons.sh &
|
43 |
|
|
fi
|
44 |
|
|
|
45 |
|
|
echo "rc.update_bogons.sh is ending the update cycle." | logger
|