0

IPv6 shortening and compressing address rules

An IPv6 address can be very long as it is a 128 bits one. Asking someone verbally to check the connectivity to a given address can be tricky :-)

There are however some rules to shorten it and it’s a way to remove zeros.

Rule 1: Suppress leading zeros

Remove all leading zeros, the left side zeros, in every 16 bits field.

For example:

2001:0db8:0000:0000:0000:0000:000:0001

will be simplified to

2001:db8:0:0:0:0:0:1

Of course 0000 becomes 0.

Rules 2: The larger sequence of :0:0: can be reduced to ::

You can compact a sequence of zeros to the symbol ::.

Applying the rule to 2001:db8:0:0:0:0:0:1 would get us 2001:db8::1.

  • You can’t compact just one :0: – only a sequence.
  • If there is more than one sequence of :0: you can only compact the large one. If they have the same length compact the first one.

2001:db8::1:1:1:1:1 is not correct. It must be 2001:db8:0:1:1:1:1:1.

2001:0:0:1:0:0:0:1 will become 2001:0:0:1::1.

2001:db8:0:0:1:0:0:1 will become 2001:db8::1:0:0:1.

That’s it.

Uncategorized
0

How to check an SSL certificate expiration date from the command line

Some days ago one of my sites certificate expired. I didn’t pay attention to the Let’s Encrypt periodic warning emails – I’m using the DNS-01 challenge.

I must create a simple script to check how many days are left and install it as a cron job.

After some search I found that curl and date could do it.

$ curl https://thejoyofstick.com -vI --stderr - | grep "expire date:" | cut -d: -f 2-
Jun 25 17:26:52 2022 GMT

$ date --date='Jun 25 17:26:52 2022 GMT' '+%s'
1656178012

$ date '+%s'
1649805603

$ echo '(1656178012-1649805603)/86400' | bc
73

We now have a way to calculate how many days are left.
You can build a bash script with these and, after checking for a countdown days threshold, send yourself a proper alert email.

For myself I’m using a perl script based on this one

#!/usr/bin/env perl

use strictures 2;
use IO::Socket::SSL;
use Net::SSLeay;
use Date::Simple ( 'date', 'today' );

my $site = shift || 'example.com';

my $client = IO::Socket::SSL->new("$site:443")
  or die "error=$!, ssl_error=$SSL_ERROR";
my $cert = $client->peer_certificate();
my $time = Net::SSLeay::X509_get_notAfter($cert);
my $asn_t = Net::SSLeay::P_ASN1_TIME_get_isotime($time);
my ($date) = split /T/, $asn_t;
my $diff = date($date) - today;
my $warning_time = 15;

print "Expire date: $date\n";
print "How many days left: $diff\n";
print "Warning before $warning_time days\n";

Added a personal email module to send a message if $diff is less than $warning_time and then cron with it.

Enjoy!

0

Problem updating Chrome: Repository changed its ‘Origin’ value from ‘Google, Inc.’ to ‘Google LLC’

If you are using the Google repository to update your Chrome it doesn’t update anymore with apt-get due to security reasons.

Reading package lists... Done                      
E: Repository 'http://dl.google.com/linux/chrome/deb stable Release' changed its 'Origin' value from 'Google, Inc.' to 'Google LLC'
N: This must be accepted explicitly before updates for this repository can be applied. See apt-secure(8) manpage for details.

The solution is fast. Just run

sudo apt update

Note that’s apt and not apt-get. And just accept the change.

Do you want to accept these changes and continue updating from this repository? [y/N]

Done!

Then just use again sudo apt-get update and sudo apt-get upgrade