Networking Forums

Networking Forums > Computer Networking > Linux Networking > Calculate if an IP belongs to a subnet

Reply
Thread Tools Display Modes

Calculate if an IP belongs to a subnet

 
 
Sashi
Guest
Posts: n/a

 
      04-12-2007, 08:59 PM
All, I'm trying to see if a given IP address belongs to a given
subnet, given the subnet and the subnet mask.

Is there a simple formula to do this?

Thanks,
Sashi

 
Reply With Quote
 
 
 
 
patrick
Guest
Posts: n/a

 
      04-12-2007, 09:05 PM
In news:(E-Mail Removed) ups.com,
Sashi <(E-Mail Removed)> wrote:

> All, I'm trying to see if a given IP address belongs to a given
> subnet, given the subnet and the subnet mask.
>
> Is there a simple formula to do this?


Search for the " ipcalc.pl " Perl script.
 
Reply With Quote
 
Joe Pfeiffer
Guest
Posts: n/a

 
      04-12-2007, 09:50 PM
"Sashi" <(E-Mail Removed)> writes:

> All, I'm trying to see if a given IP address belongs to a given
> subnet, given the subnet and the subnet mask.
>
> Is there a simple formula to do this?


It's just a bitwise and -- if ((ip & netmask) == subnet) "yes"
 
Reply With Quote
 
Sashi
Guest
Posts: n/a

 
      04-13-2007, 01:03 PM
On Apr 12, 5:50 pm, Joe Pfeiffer <pfeif...@cs.nmsu.edu> wrote:
> "Sashi" <small...@gmail.com> writes:
> > All, I'm trying to see if a given IP address belongs to a given
> > subnet, given the subnet and the subnet mask.

>
> > Is there a simple formula to do this?

>
> It's just a bitwise and -- if ((ip & netmask) == subnet) "yes"


D'uh!
Thanks,
Sashi

 
Reply With Quote
 
birre
Guest
Posts: n/a

 
      04-16-2007, 11:22 AM
On 2007-04-12 22:59, Sashi wrote:
> All, I'm trying to see if a given IP address belongs to a given
> subnet, given the subnet and the subnet mask.
>
> Is there a simple formula to do this?
>
> Thanks,
> Sashi
>


Try this:
http://www.subnet-calculator.com/


/birre
 
Reply With Quote
 
 
 
Reply

« Linux Newbie | wlan »
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
how to calculate which switch will be correct for iSCSI rogk Linux Networking 2 08-27-2010 06:03 PM
How Can I calculate EIRP? ConceptZone Wireless Internet 11 09-23-2007 06:31 AM
Wireless network doesn't work while PC belongs to a domain Fra Ja Riis Wireless Networks 1 04-25-2006 10:57 PM
Equations to calculate range? Eric Wireless Internet 8 03-28-2006 01:13 PM
How to tell if an IP address belongs to a host? Rennie deGraaf Linux Networking 0 11-27-2004 08:44 AM



1 2 3 4 5 6 7 8 9 10 11