old-www/HOWTO/archived/IP-Subnetworking/IP-Subnetworking-6.html

193 lines
8.2 KiB
HTML

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 3.2 Final//EN">
<HTML>
<HEAD>
<META NAME="GENERATOR" CONTENT="SGML-Tools 1.0.9">
<TITLE>IP Sub-Networking Mini-Howto: How to subnetwork a IP network number</TITLE>
<LINK HREF="IP-Subnetworking-7.html" REL=next>
<LINK HREF="IP-Subnetworking-5.html" REL=previous>
<LINK HREF="IP-Subnetworking.html#toc6" REL=contents>
</HEAD>
<BODY>
<A HREF="IP-Subnetworking-7.html">Next</A>
<A HREF="IP-Subnetworking-5.html">Previous</A>
<A HREF="IP-Subnetworking.html#toc6">Contents</A>
<HR>
<H2><A NAME="s6">6. How to subnetwork a IP network number</A></H2>
<P>Having decided that you need to subnetwork your IP network number, how
do you go about it? The following is an overview of the steps which will
then be explained in detail:-
<P>
<UL>
<LI>Set up the physical connectivity (network wiring and network
interconnections - such as routers;</LI>
<LI>Decide how big/small each subnetwork needs to be in terms of the
number of devices that will connect to it - ie how many usable IP
numbers are required for each individual segment.</LI>
<LI>Calculate the appropriate network mask and network addresses;</LI>
<LI>Give each interface on each network its own IP address and the
appropriate network mask;</LI>
<LI>Set up the routes on the routers and the appropriate gateways,
routes and/or default routes on the networked devices;</LI>
<LI>Test the system, fix problems and then relax!</LI>
</UL>
<P>
<P>For the purpose of this example, we will assume we are sub-networking a single C
class network number: 192.168.1.0
<P>
<P>This provides for a maximum of 254 connected interfaces (hosts), plus
the obligatory network number (192.168.1.0) and broadcast address
(192.168.1.255).
<P>
<H2><A NAME="ss6.1">6.1 Setting up the physical connectivity</A>
</H2>
<P>You will need to install the correct cabling infrastructure for all the
devices you wish to interconnect designed to meet your physical layout.
<P>
<P>You will also need a mechanism to interconnect the various segments
together (routers, media converters etc.).
<P>
<P>A detailed discussion of this is obviously impossible here. Should you
need help, there are network design/installation consultants around who
provide this sort of service. Free advice is also available on a number of
Usenet news groups (such as comp.os.linux.networking).
<P>
<H2><A NAME="ss6.2">6.2 Subnetwork sizing</A>
</H2>
<P>There is a play off between the number of subnetworks you create and 'wasted'
IP numbers.
<P>
<P>Every individual IP network has two addresses unusable as interface
(host) addresses - the network IP number itself and the broadcast
address. When you subnetwork, each subnetwork requires its own, unique
IP network number and broadcast address - and these have to be valid
addresses from within the range provided by the IP network that you are
sub-networking.
<P>
<P>So, by sub-networking an IP network into two separate subnetworks, there
are now <B>two</B> network addresses and <B>two</B> broadcast addresses -
increasing the 'unusable' interface (host) addresses; creating 4
subnetworks creates <B>eight</B> unusable interface (host) addresses and
so on.
<P>
<P>In fact the smallest usable subnetwork consists of 4 IP numbers:-
<UL>
<LI>Two usable IP interface numbers - one for the router interface on
that network and one for the single host on that network.</LI>
<LI>One network number.</LI>
<LI>One broadcast address.</LI>
</UL>
<P>
<P>Quite why one would want to create such a small network is another
question! With only a single host on the network, any network
communication must go out to another network. However, the example does
serve to show the law of diminishing returns that applies to
sub-networking.
<P>
<P>In principle, you can only divide your IP network number into 2^n (where
n is one less that the number of host bits in your IP network number)
equally sized subnetworks (you can subnetwork a subnetwork and combine
subnetworks however).
<P>
<P>So be realistic about designing your network design - you want the
<B>minimum</B> number of separate local networks that is consistent with
management, physical, equipment and security constraints!
<P>
<H2><A NAME="ss6.3">6.3 Calculating the subnetwork mask and network numbers</A>
</H2>
<P>The network mask is what performs all the <B>local</B> magic of dividing
an IP network into subnetworks.
<P>
<P>The network mask for an un-sub-networked IP network number is simply a
dotted quad which has all the 'network bits' of the network number
set to '1' and all the host bits set to '0'.
<P>
<P>So, for the three classes of IP networks, the standard network masks
are:-
<UL>
<LI>Class A (8 network bits) : 255.0.0.0</LI>
<LI>Class B (16 network bits): 255.255.0.0</LI>
<LI>Class C (24 network bits): 255.255.255.0</LI>
</UL>
<P>
<P>The way sub-networking operates is to <EM>borrow</EM> one or more of the
available host bits and make then make interfaces <B>locally</B> interpret
these borrowed bits as part of the network bits. So to divide a network
number into two subnetworks, we would borrow one host bit by setting the
appropriate bit in the network mask of the first (normal) host bit to '1'.
<P>
<P>For a C Class address, this would result in a netmask of<BR>
11111111.11111111.11111111.10000000<BR>
or 255.255.255.128
<P>
<P>For our C Class network number of 192.168.1.0, these are some of the
sub-networking options you have:-
<P>
<HR>
<PRE>
No of No of
subnets Hosts/net netmask
2 126 255.255.255.128 (11111111.11111111.11111111.10000000)
4 62 255.255.255.192 (11111111.11111111.11111111.11000000)
8 30 255.255.255.224 (11111111.11111111.11111111.11100000)
16 14 255.255.255.240 (11111111.11111111.11111111.11110000)
32 6 255.255.255.248 (11111111.11111111.11111111.11111000)
64 2 255.255.255.252 (11111111.11111111.11111111.11111100)
</PRE>
<HR>
<P>
<P>In principle, there is absolutely no reason to follow the above way of
subnetworking where network mask bits are added from the most
significant host bit to the least significant host bit. However, if you
do not do it this way, the resulting IP numbers will be in a <EM>very</EM>
odd sequence! This makes it extremely difficult for us humans to decide
to which subnetwork an IP number belongs as we are not too good at thinking
in binary (computers on the other hand are and will use whatever scheme
you tell them with equal equanimity).
<P>
<P>Having decided on the appropriate netmask, you then need to work out
what the various Network and broadcast addresses are - and the IP number
range for each of these networks. Again, considering only a C Class IP
Network number and listing only the <EM>final</EM> (host part) we have:-
<P>
<HR>
<PRE>
Netmask Subnets Network B'cast MinIP MaxIP Hosts Total Hosts
--------------------------------------------------------------------------
128 2 0 127 1 126 126
128 255 129 254 126 252
192 4 0 63 1 62 62
64 127 65 126 62
128 191 129 190 62
192 255 193 254 62 248
224 8 0 31 1 30 30
32 63 33 62 30
64 95 65 94 30
96 127 97 126 30
128 159 129 158 30
160 191 161 190 30
192 223 193 222 30
224 255 225 254 30 240
</PRE>
<HR>
<P>
<P>As can be seen, there is a very definite sequence to these numbers,
which make them fairly easy to check. The 'downside' of sub-networking is
also visible in terms of the reducing total number of available host
addresses as the number of subnetworks increases.
<P>
<P> With this information, you are now in a position to assign host and
network IP numbers and netmasks.
<P>
<HR>
<A HREF="IP-Subnetworking-7.html">Next</A>
<A HREF="IP-Subnetworking-5.html">Previous</A>
<A HREF="IP-Subnetworking.html#toc6">Contents</A>
</BODY>
</HTML>