CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    May 2010
    Posts
    6

    Can subnets and gateways be calculated?

    Hi,
    I am writing a program on Linux that requires to to setup itself with a static IP provided by a user but the gateway and subnet mask are not. Is there a way to calculate them? If not, what do you recommend as a solution, where the least preference is to ask the user to enter them.

    Thanks in advance.

  2. #2
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Can subnets and gateways be calculated?

    Well, not the gateway. The gateway IP address can be any valid address on the network. The subnet masks, on the other hand, do have default values. However, I don't know what they are, off the top of my head.

    Viggy

  3. #3
    Join Date
    May 2010
    Posts
    6

    Re: Can subnets and gateways be calculated?

    thanks MrViggy.
    I did more research and I found out some of the things you mentioned.

    3 classes with each class having its own unique set of subnets. I had to look into subnets and get a good understanding but I think I have a solution...

    Class A, subnets 255.0.0.0 up to 255.255.255.224 (depending on the bit masks and # of bits)
    Class B, subnets 255.255.0.0 up to 255.255.255.252 (depending on the bit masks and # of bits)
    Class C, subnets 255.255.255.0 up to 255.255.255.252 (depending on the bit masks and # of bits)

  4. #4
    Join Date
    Feb 2002
    Posts
    4,640

    Re: Can subnets and gateways be calculated?

    Yup, that's it. The "default" subnet is usually the first set you mention (by that, I mean the ones with '0's).

    Viggy

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured