# What's the difference between host and network address? [duplicate]

Often in the interviews there is a question 'how many hosts this network can have and how many subnetworks?'.

Let's say we have `/30` network. It has 4 addresses total, minus it's own network address and broadcast we have 2. I know these 2 can be hosts. Can they be networks?

What if each of them is, say, wifi router with their own `192.168.56.X` network. Are those wifi netowroks subnetworks of /30 and 2 router's addresses in /30 'mother' networks their network adresses?

## marked as duplicate by Ron Maupin♦Mar 18 at 0:16

It's funny you e-mailed me about this question, I'm writing another blog post at the moment that answers this very question. I should have it posted in the next few hours.

EDIT: The blog post has now been published.

Anyway, let's get started on your question :)

Let's say we have /30 network. It has 4 addresses total, minus it's own network address and broadcast we have 2. I know these 2 can be hosts.

This is spot on.

There are 32 bits in an IP address. As you've got a /30 that means 30 of those bits are "reserved" network bits. As you know, you're not "allowed" to change network bits otherwise you're more than likely end up with IP address conflicts. This therefore leaves you with 2 "Host" bits which you are "allowed" to play with.

As you correctly point out, these 2 bits result in 4 addresses. However, when we use the 2 ^ n - 2 formula to determine the number of usable host addresses we're left with two addresses. As you already know, we subtract 2 in this formula to account for the first and last addresses in the subnet as they are the network and broadcast addresses respectively and cannot be assigned to a host.

Now if I understand your question correctly you're asking can a /30 be used to create a couple of subnets. To calculate the number of subnets we'll get we need to use a formula which differs slightly from the one mentioned above - this formula is 2 ^ n (note that we do not subtract 2 here).

Let's say we use the two host bits in this calculation - 2 ^ 2 = 4 subnets. However, as this uses all of the host bits we don't have any left to allocate to the wifi routers. Because of this it would be more appropriate to use only 1 host bit for the subnet and leave the other bit for the hosts. Therefore our subnet calculation would look like this: 2 ^ 1 = 2 subnets.

However, we hit an issue here too. As as we've only got one host bit left we won't have any usable addresses because 2 ^ 1 - 2 = 0. Therefore the answer is no, you cannot subnet a /30.

Note: OK I may be fibbing a little here... there are some situations where you can use /31 and even /32 addresses (for example, loopback interfaces and point to point links) but they're another kettle of fish.

Now if you were asking about a /29 address instead, then the answer would be yes, you can use this network address to create two subnets with a couple of hosts each. Let's look at why:

• 29 bits are reserved for the network and therefore we cannot use them. This leaves us with 3 bits.
• If we use one of these bits for our subnets we'd be given two subnets (2 ^ 1 = 2). This leaves us with 2 bits for hosts.
• Running these 2 left over bits through the above mentioned formula, we're left with two hosts per subnet (2 ^ 2 - 2 = 2).

The above means we'd have two subnets with two usable host addresses each. Or to word it a little differently, we'd have four usable addresses spread across two subnets.