repo: iptools action: blob revision: path_from: dicks revision_from: refs/heads/master: path_to: revision_to:
blob of:
/ dicks
refs/heads/master:/dicks
#!/usr/bin/env bash
### this is used to generate a bird config file that can be included to block IP ranges based on ASN
### I have this script in a cronjob that runs weekly. I'm not sure of the best time period.
dir=/etc/bird
echo "protocol static DICKS {" > "${dir}/dicks.conf.new"
echo "ipv4 {};" >> "${dir}/dicks.conf.new"
grep '^[0-9./][0-9./]*$' "${dir}/manual-dicks.list" | sed 's/^/route /g;s/$/ unreachable;/g' >> "${dir}/dicks.conf.new"
## one ASN per line, only digits. anything else is ignored.
grep '^[0-9][0-9]*$' "${dir}/asn.list" | while read as;do
ASN-to-list.sh "${as}" | sed 's/^/route /g;s/$/ unreachable;/g' >> "${dir}/dicks.conf.new"
done
echo "};" >> "${dir}/dicks.conf.new"
mv /etc/bird/dicks.conf.new /etc/bird/dicks.conf
echo "protocol static DICKS6 {" > "${dir}/dicks6.conf.new"
echo "ipv6 {};" >> "${dir}/dicks6.conf.new"
grep '[0-9a-f.:/][0-9a-f.:/]' "${dir}/manual-dicks6.list" | sed 's/^/route /g;s/$/ unreachable;/g' >> "${dir}/dicks6.conf.new"
grep '^[0-9][0-9]*$' "${dir}/asn.list" | while read as;do
ASN-to-list6.sh "${as}" | sed 's/^/route /g;s/$/ unreachable;/g' >> "${dir}/dicks6.conf.new"
done
echo "};" >> "${dir}/dicks6.conf.new"
mv /etc/bird/dicks6.conf.new /etc/bird/dicks6.conf
birdc configure