Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??

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.


In reply to IP addresses that might have hostnames in roman numerals by tomhukins

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • Outside of code tags, you may need to use entities for some characters:
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others browsing the Monastery: (8)
    As of 2014-12-25 07:59 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      Is guessing a good strategy for surviving in the IT business?





      Results (159 votes), past polls