Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot
 
PerlMonks  

Managing your IP space with Perl

by fokat (Deacon)
on Aug 15, 2002 at 19:02 UTC ( [id://190497]=perltutorial: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    use NetAddr::IP;
    my $ip = new NetAddr::IP '127.0.0.1';
    
  2. or download this
    use NetAddr::IP;
    my $loopback = new NetAddr::IP '127.0.0.1', '255.0.0.0';
    my $rfc1918 = new NetAddr::IP '10.0.0.0/8';
    my $another = new NetAddr::IP '1.2.0.0/255.255.0.0';
    my $loopback2 = new NetAddr::IP 'loopback';
    
  3. or download this
    use NetAddr::IP;
    my $ip = new NetAddr::IP('10.0.0.0/30');
    ...
      print "ip = $ip\n";
      $ip ++;
    }
    
  4. or download this
    ip = 10.0.0.0/30
    ip = 10.0.0.1/30
    ip = 10.0.0.2/30
    
  5. or download this
    use NetAddr::IP;
    my $ip = new NetAddr::IP('10.0.0.0/30');
    print join(' ', @$ip), "\n";
    
  6. or download this
    10.0.0.1/32 10.0.0.2/32
    
  7. or download this
    use NetAddr::IP;
    
    ...
    10.0.64.0/18
    10.0.192.0/18
    10.0.160.0/19
    
  8. or download this
    use NetAddr::IP;
    
    print "My address space contains the following /24s:\n", 
        join("\n", NetAddr::IP->new('10.0.0.0/22')->split(24)), "\n";
    
  9. or download this
    use NetAddr::IP;
    
    print join(' ', NetAddr::IP->new('10.0.0.0/25')->wildcard());
    
  10. or download this
    use NetAddr::IP;
    
    ...
    10.128.0.41
    10.128.0.17
    10.128.0.19
    
  11. or download this
    use NetAddr::IP;
    
    ...
    __DATA__
    10.0.0.0/16
    172.16.0.0/24
    
  12. or download this
    use NetAddr::IP;
    
    ...
    __DATA__
    10.0.0.0/16
    172.16.0.0/24
    
  13. or download this
    use NetAddr::IP;
    
    ...
    __DATA__
    10.0.0.0/16
    172.16.0.0/24
    

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perltutorial [id://190497]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (7)
As of 2024-04-23 18:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found