Get the subnet mask

Discussion in 'Ruby' started by David Corticchiato, Dec 19, 2006.

  1. Hi,

    Is there another way of getting my subnet mask without parsing
    ipconfig/ifconfig ?

    David.

    --
    Posted via http://www.ruby-forum.com/.
    David Corticchiato, Dec 19, 2006
    #1
    1. Advertising

  2. David Corticchiato

    Jan Svitok Guest

    On 12/19/06, David Corticchiato <> wrote:
    > Hi,
    >
    > Is there another way of getting my subnet mask without parsing
    > ipconfig/ifconfig ?
    >
    > David.


    On linux, look somewhere in the /proc

    On windows there's some WINAPI for sure, but it could be PITA to go
    through all the structures. Or try WMI (through Win32OLE) -- have look
    at msdn.

    It depends on your needs, but parsing ipconfig is the easiest way (be
    sure to take care of localisation, we had problems when we moved from
    english to, say italian windows.)

    You can guess the netmask from the address class, but most probably
    that won't work.
    Jan Svitok, Dec 19, 2006
    #2
    1. Advertising

  3. David Corticchiato wrote:
    > Hi,
    >
    > Is there another way of getting my subnet mask without parsing
    > ipconfig/ifconfig ?
    >
    > David.
    >


    There's IPAddr#mask, from the 'ipaddr' library (part of the stdlib).
    Does that help?

    Regards,

    Dan
    Daniel Berger, Dec 19, 2006
    #3
  4. David Corticchiato

    Shiwei Zhang Guest

    Daniel Berger wrote:

    > David Corticchiato wrote:
    >
    >> Hi,
    >>
    >> Is there another way of getting my subnet mask without parsing
    >> ipconfig/ifconfig ?
    >>
    >> David.
    >>

    >
    > There's IPAddr#mask, from the 'ipaddr' library (part of the stdlib).
    > Does that help?
    >
    > Regards,
    >
    > Dan
    >

    IPAddr#mask can't meet this requirement I think.
    If the methods for these kinds of requirements (e.g., to get Subnet
    Mask, Ip Addr of the local machine) are not available for now, should we
    provide them in the near future?
    Shiwei Zhang, Jan 12, 2007
    #4
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Glenn M

    Get Requesting Clients Subnet Mask

    Glenn M, Oct 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    414
    John Saunders
    Oct 12, 2004
  2. Pierre Rouleau
    Replies:
    0
    Views:
    383
    Pierre Rouleau
    Dec 10, 2003
  3. yagru_alvarez
    Replies:
    7
    Views:
    597
    Michael Doubez
    Jun 6, 2011
  4. kielhd
    Replies:
    3
    Views:
    329
    John W. Krahn
    Nov 9, 2003
  5. 187
    Replies:
    2
    Views:
    528
    Bart Lateur
    Jul 29, 2004
Loading...

Share This Page