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. Advertisements

  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. Advertisements

  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. Advertisements

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. Vijesh
    Replies:
    0
    Views:
    573
    Vijesh
    Nov 27, 2004
  2. Glenn M

    Get Requesting Clients Subnet Mask

    Glenn M, Oct 12, 2004, in forum: ASP .Net
    Replies:
    1
    Views:
    550
    John Saunders
    Oct 12, 2004
  3. Sascha Teifke
    Replies:
    2
    Views:
    3,106
    Sascha Teifke
    Jun 28, 2003
  4. Pierre Rouleau
    Replies:
    0
    Views:
    516
    Pierre Rouleau
    Dec 10, 2003
  5. yagru_alvarez
    Replies:
    7
    Views:
    1,048
    Michael Doubez
    Jun 6, 2011
  6. Marcin Tyman

    Conversion mask in hex to bit mask

    Marcin Tyman, May 6, 2008, in forum: Ruby
    Replies:
    4
    Views:
    1,219
    Robert Klemme
    May 6, 2008
  7. kielhd
    Replies:
    3
    Views:
    485
    John W. Krahn
    Nov 9, 2003
  8. 187
    Replies:
    2
    Views:
    883
    Bart Lateur
    Jul 29, 2004
Loading...