http://www.perlmonks.org?node_id=540074

During an idle moment recently, I wondered if any IP addresses I use might have potentially valid hostnames matching their address. Does that make sense?

Here's an example: the IP address 1.2.3.4 might have the hostname i.ii.iii.iv, but unfortunately the top level domain name .iv doesn't exist.

So, I wrote a script that grabs the list of country-specific TLDs and checks IP addresses you specify to see if any might have hostnames in roman numerals:

#!/usr/bin/perl use strict; use warnings; use LWP::Simple qw(mirror); use Roman qw(roman); use Fatal qw(open close mirror); my %ip_to_roman = do { my @ip = <DATA>; chomp @ip; map { $_ => roman_ip($_) } @ip; }; { mirror('http://www.iana.org/cctld/cctld-whois.htm', 'cctld-whois.h +tm'); open(my $fh, 'cctld-whois.htm'); my $page = do { local $/ = undef; <$fh> }; close $fh; while ($page =~ m{>\.(\w\w)(?:&nbsp;|&#150;)*([^<]+)}gms) { my ($tld, $country) = ($1, $2); $country =~ s/\s+/ /ms; IP: foreach my $address (keys %ip_to_roman) { next IP unless $ip_to_roman{$address} =~ m/\.$tld\z/ms; print "$address is $ip_to_roman{$address} in $country\n"; } } } sub roman_ip { my $ip = shift; return join '.', map { roman $_ } split(/\./, $ip); } # Put your IP addresses here __DATA__ 1.2.3.4 5.6.7.8

This script has limitations: it reports some domain names that you can't register. Many TLDs, such as .uk do not allow arbitrary registrations such as foo.uk. Instead, you have to register foo.co.uk, foo.org.uk, etc.

So, what did I find out about my own addresses? I now know I want to register a .ci domain name, but apparently I need to get someone in the Ivory Coast to register this for me and I suspect this may not work as they might only allow .co.ci or .com.ci.

Anyway, it was still a fun experiment.

Replies are listed 'Best First'.
Re: IP addresses that might have hostnames in roman numerals
by Ultra (Hermit) on Mar 30, 2006 at 05:46 UTC

    Is there any place in the world where they write IP addresses in roman notation?!

    Dodge This!

      Sure they do. Have a look at these crazy Finns!

      DXXXVII.wdyn.saunalahti.fi[62.142.9.238] CCXLVIII.wdyn.saunalahti.fi[62.142.110.248] KDCCCLVIII.dsl.saunalahti.fi[195.74.14.158] CDXXVIII.wdyn.saunalahti.fi[62.142.9.129] MKXCVII.dsl.saunalahti.fi[62.142.33.197] MKCXXVII.dsl.saunalahti.fi[62.142.33.227] MKCXXVII.dsl.saunalahti.fi[62.142.33.227] KDCCXVIII.dsl.saunalahti.fi[195.74.14.18] CDXXVIII.wdyn.saunalahti.fi[62.142.9.129] XVII.wdyn.saunalahti.fi[62.142.110.17] YMMMXXXVIII.dsl.saunalahti.fi[62.142.236.138] CDLXXXVII.tun.saunalahti.fi[213.169.25.187] DCVII.tun.saunalahti.fi[213.169.26.7] LXXXVIII.tun.saunalahti.fi[213.169.24.88] MCCXVIII.tun.saunalahti.fi[213.169.28.18] YYYDCCXXXVII.dsl.saunalahti.fi[85.76.2.38]

      Somewhere, a bofh is laughing his head off :)

      • another intruder with the mooring in the heart of the Perl

        ouch!

        Dodge This!
      Is there any place in the world where they write IP addresses in roman notation?!

      I can't think of anywhere where people usually do it, but what's wrong with following the robustness principle - be strict in what you generate; be liberal in what you accept - to the absurd?

      I like the idea of things like telnet x.i.xi.ii just working. Traditionalists can stick to telnet 10.1.11.2. TIMTOWTDI.