IP Sub-Networking Mini-Howto: How to subnetwork a IP network number

Next Previous Contents

## 6. How to subnetwork a IP network number

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:-

- Set up the physical connectivity (network wiring and network interconnections - such as routers;
- 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.
- Calculate the appropriate network mask and network addresses;
- Give each interface on each network its own IP address and the appropriate network mask;
- Set up the routes on the routers and the appropriate gateways, routes and/or default routes on the networked devices;
- Test the system, fix problems and then relax!

For the purpose of this example, we will assume we are sub-networking a single C class network number: 192.168.1.0

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).

## 6.1 Setting up the physical connectivity

You will need to install the correct cabling infrastructure for all the devices you wish to interconnect designed to meet your physical layout.

You will also need a mechanism to interconnect the various segments together (routers, media converters etc.).

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).

## 6.2 Subnetwork sizing

There is a play off between the number of subnetworks you create and 'wasted' IP numbers.

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.

So, by sub-networking an IP network into two separate subnetworks, there are now two network addresses and two broadcast addresses - increasing the 'unusable' interface (host) addresses; creating 4 subnetworks creates eight unusable interface (host) addresses and so on.

In fact the smallest usable subnetwork consists of 4 IP numbers:-

- Two usable IP interface numbers - one for the router interface on that network and one for the single host on that network.
- One network number.
- One broadcast address.

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.

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).

So be realistic about designing your network design - you want the minimum number of separate local networks that is consistent with management, physical, equipment and security constraints!

## 6.3 Calculating the subnetwork mask and network numbers

The network mask is what performs all the local magic of dividing an IP network into subnetworks.

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'.

So, for the three classes of IP networks, the standard network masks are:-

- Class A (8 network bits) : 255.0.0.0
- Class B (16 network bits): 255.255.0.0
- Class C (24 network bits): 255.255.255.0

The way sub-networking operates is to borrow one or more of the available host bits and make then make interfaces locally 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'.

For a C Class address, this would result in a netmask of
11111111.11111111.11111111.10000000
or 255.255.255.128

For our C Class network number of 192.168.1.0, these are some of the sub-networking options you have:-

    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)

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 very 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).

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 final (host part) we have:-

    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

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.

With this information, you are now in a position to assign host and network IP numbers and netmasks.

Next Previous Contents