Hello Deepika1312 and welcome to the manastery and to the wonderful world of Perl!

from the little I know about networking what you want is not possible: given the lonely IP address you cannot desume what the netmask value is. Infact the net can be subnetted at will resulting in a serie of a little subnets.

If you are looking to the local IP configured in some host you can retrieve how the network card is configured but it can be also misconfigured: so you cannot be sure if the mask is the rigth one.

By other hand if you know the net (not just an IP) you can retrieve useful informations using NetAddr::IP for example (warning windows double quotes!):

perl -MNetAddr::IP -e "$ip=new NetAddr::IP '189.10.136.129/27'; print +'net ',$ip,' mask ',$ip->mask,' first ',$ip->first,' last ',$ip->last +" net 189.10.136.129/27 mask 255.255.255.224 first 189.10.136.129/27 las +t 189.10.136.158/27

L*

There are no rules, there are no thumbs..
Reinvent the wheel, then learn The Wheel; may be one day you reinvent one of THE WHEELS.

In reply to Re: Subnet Address details from ip address by Discipulus
in thread Subnet Address details from ip address by Deepika1312

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!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • 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, details, 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, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            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.