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

Re^2: Splitting IP ranges depending on overlap conditions

by fishbot_v2 (Chaplain)
on Apr 14, 2006 at 17:49 UTC ( [id://543404]=note: print w/replies, xml ) Need Help??


in reply to Re: Splitting IP ranges depending on overlap conditions
in thread Splitting IP ranges depending on overlap conditions

TMTOWTDI, and I normally do this sort of thing:

use strict; use warnings; use Socket qw{ inet_aton inet_ntoa }; sub ip_to_num { unpack( 'N', inet_aton( shift )); } sub ip_to_str { inet_ntoa( pack( 'N', shift )); } sub ip_plus { ip_to_str( ip_to_num( $_[0] ) + $_[1] ); } sub ip_minus { ip_plus( $_[0], -$_[1] ); } my $dotted_quad = '10.198.9.2'; print ip_plus( $dotted_quad, 290 ), "\n"; print ip_minus( $dotted_quad, 3 ), "\n"; __END__ 10.198.10.36 10.198.8.255

In the OPs case, he only needs to add 1 and subtract 1. Again, all of this craps out on IPv6. I suspect that isn't a concern yet.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others having a coffee break in the Monastery: (5)
As of 2024-04-18 00:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found