Make a random IP address in Perl

This Perl script makes reasonably convincing random IPv4 internet addresses.

use warnings;
use strict;
sub randomip
    my @digits;
    for (0..3) {
        push @digits, int (rand (255) + 1);
    return join '.', @digits;
for (0..9) {
    print randomip (), "\n";


The output looks like this:


Copyright © Ben Bullock 2009-2021. All rights reserved. For comments, questions, and corrections, please email Ben Bullock ( or use the discussion group at Google Groups. News about the site. / Privacy / Disclaimer