File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Sockets and Internet Protocols and the fly likes NetMask,IPAddress clarification Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of REST with Spring (video course) this week in the Spring forum!
JavaRanch » Java Forums » Java » Sockets and Internet Protocols
Bookmark "NetMask,IPAddress clarification" Watch "NetMask,IPAddress clarification" New topic

NetMask,IPAddress clarification

Vignesh C Kottaiveedu

Joined: Jan 27, 2004
Posts: 1
Hi ,
Iam developing a web-service which has the given functionality.
a) Any client registers to a web-service and that is given back a client-identity-key which comprises of ip and a secret key.
b) The second time the client comes with the idetity-key to the service and the service authenticates the client through the service.
Here is the issue , during resgistation i can get the IP address of the client , but i need to get the netmask of the ipaddress coming through http. so that i combine the ip+netmask and give back to the client. During authentication i verify the client comes from the same IP if not atleast from the same netmask. (for VB clients there is a new IP given everytime the machine is rebooted ,and also the service is within the firewall)
Here are the list of questions :
1) How do i get a netmask from a given IP address ?
2) How do i get to find that a given IP falls inside the same network when given a netmask ?
This is a very urgent requirement , please help me out.
Ernest Friedman-Hill
author and iconoclast

Joined: Jul 08, 2003
Posts: 24195

The subnet mask is a number used in interpreting an address. You can't derive a subnet mask from the address -- if you could, then what good would it be? It wouldn't add any information, right?
On top of this, these days, the notion of an address is very flexible. A NAT box can be used to hide thousands of machines behind a single IP address (which would obviously spell doom for your authentication scheme!)
So I think your whole scheme needs to be rethought.

[Jess in Action][AskingGoodQuestions]
I agree. Here's the link:
subject: NetMask,IPAddress clarification
It's not a secret anymore!