DN42 is a wonderful project that allows you to develop your BGP skills without breaking the product environment, without having to have expensive devices to make a lab to do simulations with GNS3. At the same time, it should not be a purely laboratory environment in which there are no real-world problems. I participate with 1 node in the project for about a year. One of the problems in the project is 1:1 with the real world – when someone announces prefixes that they shouldn't announce. Because I'm lazy and I don't write filters by hand all the time, I solved the problem with an elementary bash script that generates a prefix-list named dn42 and I pour the valid prefixes in it.

#!/bin/bash</pre>
vtysh -c 'conf t' -c "no ip prefix-list dn42"; #drop old prefix list

while read pl
do
vtysh -c 'conf t' -c "$pl"; #insert prefix list row by row
done < <(curl -s https://ca.dn42.us/reg/filter.txt | grep -e ^[0-9] | awk '{ print "ip prefix-list dn42 seq " $1 " " $2 " " $3 " ge " $4 " le " $5}' | sed "s_/\([0-9]\+\) ge \1_/\1_g;s_/\([0-9]\+\) le \1_/\1_g");
vtysh -c 'wr' #write new prefix list

The list of valid prefixes is taken https://ca.dn42.us/reg/filter.txt from where the main pipeline + a few modifications on my part to be able to generate prefix sheets. Commands are executed through vtysh.

Mozilla Thunderbird

The idea is identical to my post Firefox databases VACUUM and REINDEX. For some time now, Debian has lost the rebranded versions of Mozilla products. When I migrated from Icedowe to Thunderbird, I thought about it, that I have not defragmented my database, and so far a serious amount of letters have leaked through my email client, email accounts and servers, users and passwords. The script is identical to the one from my previous post only with a slight modification for where to look for the files 🙂

Linux version

for db in $(find ~/.thunderbird/$(grep Path ~/.thunderbird/profiles.ini | cut -d'=' -f2) -maxdepth 1 -name "*.sqlite" -type f)
do
echo "VACUUM ${db}"
sqlite3 ${db} VACUUM
sqlite3 ${db} REINDEX
done

Mac os version

for db in $(find ~/Library/Thunderbird/$(grep Path ~/Library/Thunderbird/profiles.ini | cut -d'=' -f2)  -maxdepth 1  -name "*.sqlite" -type f)
do
echo "VACUUM && REINDEX ${db}"
sqlite3 "${db}" VACUUM;
sqlite3 "${db}" REINDEX;
done

Unlike Firefox's profile folder, Thunderbird's is in a pretty good way (without space) and no change to the delimiter is required.

A clever trick to improve the speed of your firefox browser is by vacuuming its sqlite database. The VACUUM process rebuilds the database, thus defragmenting it, reduces the size and makes searching in it faster, using disk more efficiently may also reduce the load on your disk as it reads in sequence from my sectors. In general, this applies to any database that does not automatically perform vacuum / defrag on itself.

The process of defragmenting the Firefox database itself is quite trivial – we perform sqlite3 db-file VACUUM in the firefox profile directory. In linux, the path to it is usually ~ / .mozilla / firefox / random-name.default. In principle, you should only have 1 directory in .mozilla / firefox if you have more you can check ~ / .mozilla / firefox / profiles.ini for the correct directory in your browser's profile. Since I don't care about doing the process by hand, I wrote an elementary script to defragment the databases.:

for db in $(find ~/.mozilla/firefox/$(grep Path ~/.mozilla/firefox/profiles.ini | cut -d'=' -f2) -maxdepth 1 -name "*.sqlite" -type f)
do
   echo "VACUUM ${db}"
   sqlite3 ${db} VACUUM
   sqlite3 ${db} REINDEX
done

After executing the script, the search in the history and the loading of the fox itself is significantly faster. I guess the script can be used in Mac OS with small modifications.

p.s Here is the option for Mac OS X. – tested on Mac OS X Sierra. We have to force the delimiter to be a new line because of space in the path to the folder that contains the firefox profile

OIFS="$IFS"
IFS=$'\n'
for db in $(find ~/Library/Application\ Support/Firefox/$(grep Path ~/Library/Application\ Support/Firefox/profiles.ini | cut -d'=' -f2)  -maxdepth 1  -name "*.sqlite" -type f)
do
echo "VACUUM && REINDEX ${db}"
sqlite3 "${db}" VACUUM;
sqlite3 "${db}" REINDEX;
done

Certification in ipv6.he.net have daily tests that give on 1 an extra point after passing all the basic tests. They have to be done 100 such tests for maximum score 😐 . The tests themselves are completely trivial

  • Traceroute
  • DIG AAAA
  • DIG PTR
  • Ping
  • Whois

The most unpleasant thing is that the tests themselves must be unique, ie you can't use one domain twice 🙂 Besides everything else, they are a bit annoying 🙄 – no challenge just slapping 5 commands in the cli and copy / paste of the result on their site.

As a lazy and administrator who likes to make his life easier, I quickly scratched an elementary bash that does the dirty work for me.

#!/bin/bash

hr() {
  local start=$'\e(0' end=$'\e(B' line='qqqqqqqqqqqqqqqq'
  local cols=${COLUMNS:-$(tput cols)}
  while ((${#line} < cols)); do line+="$line"; done
  printf '%s%s%s\n' "$start" "${line:0:cols}" "$end"
}

if [ -z $1 ]
then
  echo "Append domain afert the script name!!!"
  exit
fi

IP=$(dig $1 AAAA +short)

if [ -z ${IP} ]
then
  echo "$1 dont have valid IPv6 record"
else
  reset
  traceroute6 $1
  hr
  dig $1 AAAA
  hr
  dig -x ${IP}
  hr
  ping6 -c3 ${IP}
  hr 
  whois ${IP}
fi

As you can see, the script is insanely simple. You submit a domain and then validate it to see if there is an IPv6 record and if so, perform daily tests for it. The coolest part – function hr which prints a line across the entire width of the screen is taken from bash-hackers.

One of the things that annoys me the most is when I copy / move a great director in cli I have no idea what percentage of the total size I have rolled over. Unfortunately, cp / mv do not have such forces and we have to resort to alternatives. There are a lot of possibilities, but I personally like the use of rsync instead of pc / mv. It has everything built-in – preserve rights over files and directories, progress bar as well as the ability to delete copied files.

In general, I did 2 alias that do more than wonderful work:

alias cpi='rsync -a --info=progress2'
alias mvi='rsync -a --info=progress2 --remove-source-files'