Help with Network Address Math

Top Page
Attachments:
Message as email
+ (text/plain)
Delete this message
Reply to this message
Author: Thomas Cameron
Date:  
Subject: Help with Network Address Math
Pete -

Go to ftp://ftp.camerontech.com/pub/rh133/133.pdf for the PDF of a book
I wrote with Moe Pitman about Red Hat 7.x. Look in Chapter 37, page 295
- there is a long, fairly detailed explanation for ip subnetting and
such.

I will leave it there until you tell me you've gotten it - I don't want
to leave it there for long, so please grab it ASAP. Be aware that it is
about 9.5 megs. It's a big book, over 450 pages. I produced it with
KLyX, so it doesn't look good on the screen but it prints nicely.

You can also use the ipcalc command (comes with RH I know, other distros
I am not sure).

Say you have an ip address of 209.163.156.2 with a netmask of
255.255.255.192, and you want to know the network address:

[root@thomas root]# ipcalc -n 209.163.156.2 -m 255.255.255.192
NETMASK=255.255.255.192
NETWORK=209.163.156.0

Now say you want to know the broadcast address:

[root@thomas root]# ipcalc -b 209.163.156.2 -m 255.255.255.192
NETMASK=255.255.255.192
BROADCAST=209.163.156.63

Look at the output from ipcalc --help for usage, and e-mail me if you
need any help.

Regards,
Thomas Cameron, RHCE, CNE, MCSE, MCT
Cameron Technical Services, Inc.
http://www.camerontech.com/
(512) 454-3200

On Thu, 2003-08-07 at 15:10, AZ Pete wrote:
> Calling all network gurus :)
>
> My IP network address math is rather rusty (it's been a long time!!). I have need to calculate whether a given client
> IP address is within a given network. Additionally, if there are a list of given networks, which one is the most
> specific. I need the math formulas to calculate these figures for use within an application.
>
> Examples:
> Given the network: 192.168.1.0/24
> Given IP address is: 192.168.1.100
>
> What is the formula to determine if this client's IP address falls within the network's range.
>
> Further example
> Given these networks: 192.168.1.0/24 and 192.168.0.0/16
> and the client IP of: 192.168.1.100
>
> In this case the client's IP falls within both networks. What is the formula to determine which network is the more
> specific one?
>
> Any help would be most appreciated.
> Thanks,
> Peter
> ---------------------------------------------------
> PLUG-discuss mailing list -
> To subscribe, unsubscribe, or to change you mail settings:
> http://lists.PLUG.phoenix.az.us/mailman/listinfo/plug-discuss