Project

General

Profile

Download (2.27 KB) Statistics
| Branch: | Tag: | Revision:
1
#!/bin/sh
2

    
3
# Update bogons file
4
# Part of the pfSense project
5
# www.pfsense.com
6

    
7
echo "rc.update_bogons.sh is starting up." | logger
8

    
9
# Sleep for that time, unless an argument is specified.
10

    
11
if [ "$1" = "" ]; then
12
    # 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
fi    
17

    
18
echo "rc.update_bogons.sh is beginning the update cycle." | logger
19

    
20
# Mount RW if needed
21
/etc/rc.conf_mount_rw
22

    
23
/usr/bin/fetch -q -o /tmp/bogons "http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt"
24
/usr/bin/fetch -q -o /tmp/bogonsv6 "http://files.pfsense.org/mirrors/fullbogons-ipv6.txt"
25
if [ ! -f /tmp/bogons ]; then
26
	echo "Could not download http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt" | logger
27
	dl_error="true"
28
fi
29
if [ ! -f /tmp/bogonsv6 ]; then
30
	echo "Could not download http://files.pfsense.org/mirrors/fullbogons-ipv6.txt" | logger
31
	dl_error="true"
32
fi
33

    
34
if [ "$dl_error" != "" ];then
35
	# Relaunch and sleep
36
	sh /etc/rc.update_bogons.sh & 
37
	exit
38
fi
39

    
40
BOGON_MD5=`/usr/bin/fetch -q -o - "http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt.md5" | awk '{ print $4 }'`
41
ON_DISK_MD5=`md5 /tmp/bogons | awk '{ print $4 }'`
42
if [ "$BOGON_MD5" = "$ON_DISK_MD5" ]; then
43
	egrep -v "^192.168.0.0/16|^172.16.0.0/12|^10.0.0.0/8" /tmp/bogons > /etc/bogons
44
	/etc/rc.conf_mount_ro
45
	RESULT=`/sbin/pfctl -t bogons -T replace -f /etc/bogons 2>&1`
46
	rm /tmp/bogons
47
	echo "Bogons file downloaded:  $RESULT" | logger
48
else
49
	echo "Could not download http://files.pfsense.org/mirrors/bogon-bn-nonagg.txt.md5 (md5 mismatch)" | logger
50
	# Relaunch and sleep
51
	sh /etc/rc.update_bogons.sh & 	
52
fi
53

    
54
BOGON_MD5=`/usr/bin/fetch -q -o - "http://files.pfsense.org/mirrors/fullbogons-ipv6.txt.md5" | awk '{ print $4 }'`
55
ON_DISK_MD5=`md5 /tmp/bogonsv6 | awk '{ print $4 }'`
56
if [ "$BOGON_MD5" = "$ON_DISK_MD5" ]; then
57
	egrep -v "^#" /tmp/bogonsv6 > /etc/bogonsv6
58
	/etc/rc.conf_mount_ro
59
	RESULT=`/sbin/pfctl -t bogonsv6 -T replace -f /etc/bogonsv6 2>&1`
60
	rm /tmp/bogonsv6
61
	echo "Bogons files downloaded:  $RESULT" | logger
62
else
63
	echo "Could not download http://files.pfsense.org/mirrors/fullbogons-ipv6.txt.md5 (md5 mismatch)" | logger
64
	# Relaunch and sleep
65
	sh /etc/rc.update_bogons.sh & 	
66
fi
67

    
68
echo "rc.update_bogons.sh is ending the update cycle." | logger
69

    
(97-97/107)