Tag Archives: CLI

Converting IDNs in Ubuntu

With the start of Internationalized domain names (IDNs) it sparked my interest since it requires conversion to punycode in order to continue working with existing DNS systems/applications, which work with ASCII.

Taking a search through Ubuntu’s APT system, to see whether any IDN related tools are available…

$ apt-cache search punycode

libidn11 - GNU Libidn library, implementation of IETF IDN specifications
libidn11-dev - Development files for GNU Libidn, an IDN library
idn - Command line and Emacs interface to GNU Libidn
libidn11-java - Java port of the GNU Libidn library, an IDN implementation
libidna-punycode-perl - encodes Unicode string in Punycode

There’s the idn package!  Which allows encoding of IDNs in punycode in the command line…

Doing an install…

$ sudo apt-get install idn -y

And trying it out!

$ idn правительство.рф

libidn 1.15
Copyright 2002, 2003, 2004, 2005, 2006, 2007, 2008, 2009 Simon Josefsson.
GNU Libidn comes with NO WARRANTY, to the extent permitted by law.
You may redistribute copies of GNU Libidn under the terms of
the GNU Lesser General Public License.  For more information
about these matters, see the file named COPYING.LIB.

And resolving the domain…

$ nslookup xn--80aealotwbjpid2k.xn--p1ai

Non-authoritative answer:
Name:	xn--80aealotwbjpid2k.xn--p1ai

Note that resolving the domain directly results in rubbish!

$ nslookup правительство.рф

Non-authoritative answer:
Name:	208191209128208176208178208184209130208181208187209140209129209130208178208190.209128209132

So, basically from this we understand that applications will need to use the punycode encoded version of the IDN, NOT the original IDN, when resolving.  And there’re tools out there already can do that for us.

Since Ubuntu has these packages, Debian would also have the corresponding packages available too.


Getting your server to send an email whenever anyone logs in

Running on a VPS like Linode give me plenty of control over what is run, and also plenty of chances to learn more about network administration (along with the heartaches). 😛

The code that I used was based from this forum post. This one presumes that your MTA has been setup properly. The original code was for protecting your root account (i.e. when anyone logs into your server’s root account, you get the notification).

(Note: it is usually not advisable to login as root. Create a user account and give it sudoer rights instead. I’d say that’s advisable even for servers where there is only one person expected to login, which is you.)

[Edit: a more powerful, updated version of this script can be found here]

Continue reading Getting your server to send an email whenever anyone logs in