[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: 2 variables in R. Ziegler's book



On Tue, Apr 24, 2001 at 10:16:12AM +0100, Michael Boyd wrote:
> Hello,
> 
> I am constructing my ipchains ruleset at the moment following
> the example in R. Ziegler's Linux Firewalls.  In the section
> on smurf attacks he uses 2 variables which seem not to be
> declared anywhere, $NETMASK and $NETWORK.
[snip]
> Can anyone tell me what they are?  I presume NETMASK is fairly obvious
> but don't know what to enter for NETWORK.

They are not predefined.

I have not looked at that book, but he's probably just using
them (without stating it explicitly) to mean that you should
fill in your own network and netmask there.

An IP address of 192.168.5.3, along with a netmask of
255.255.255.0 means the network address is 192.168.5.0.  But,
with a netmask of 255.255.0.0, the network address would be
192.168.0.0.  With a netmask of 255.0.0.0, the network address
would be 192.0.0.0.  Get the idea? :)

Just take the binary representation of the IP address:
e.g. 172.17.5.3 -> 10101100.00010001.00000101.00000011

and the binary representation of the netmask:
e.g. 255.240.0.0 -> 11111111.11110000.00000000.00000000

Then just bitwise AND them together:

10101100.00010001.00000101.00000011
11111111.11110000.00000000.00000000
- ---------------------------------
10101100.00010000.00000000.00000000
- ---------------------------------

And you get the network address.

In this example, 172.16.0.0.

Hope this helps :)

-- 
Michael Wood        | Tel: +27 21 762 0276 | http://www.kingsley.co.za/
wood@kingsley.co.za | Fax: +27 21 761 9930 | Kingsley Technologies



Reply to: