Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get gateway address when subnetting?

I have to subnet a network from a single class C IP address.

I have figured out the subnet mask and the broadcast address (I'm using subnet mask /28) but don't understand how to get the gateway address.

Can anyone help me?

like image 699
toby Avatar asked Dec 16 '22 14:12

toby


2 Answers

If subnet mask is 255.255.255.248 then number of masked bit will be 5, hence number of subnets = 2. The power number of masked bits = 2 the power 5 = 32 subnets, and the number of hosts per subnets = 2. The power (unmasked bit or 32- total number of network bits) = 2 the power (32-29) = 8 host/subnet.

Hence:

  • 1) IP's in subnet-1 will be from 192.168.1.0 to 192.168.1.7 where 192.168.1.0 will be subnet id and 192.168.1.7 will be broadcast id.

  • 2) IP's in subnet-2 will be from 192.168.1.8 to 192.168.1.15

and so on............

  • 32) IP's in subnet-32 will be from 192.168.1.248 to 192.168.1.255.....

The gateway is only one for a network i.e. the first IP address of that network.

like image 126
Rajneesh Tiwari Avatar answered Dec 19 '22 04:12

Rajneesh Tiwari


This post is almost 8 years old, but in case someone wanders across this, I wanted to fix a few issues with the top voted comment. I would've commented directly, but I literally just started this account, so I don't have the authority to do that.

  1. A subnet mask of /28 would be 255.255.255.240, not 248, not 248.
  2. Having 32 subnets with 8 hosts per subnet is impossible with the given mask.

The purpose of the mask is that is shows which bits within a network can and can't change. 240 in binary = 1111 0000. This means the first 4 msb in the last value cannot change AND be in the same network.

So let's say your network address is 192.168.1.0/28. Write the last decimal value (0) out in binary with 8 bits. 0000 0000. Since 240 comes out to 1111 0000, the first 4 bits must remain unchanged in order to be subnets on the same network.

From here, subnets and hosts are determined by the last 4 bits. You can have 2 subnets with 6 hosts/subnet or 4 subnets with 2 hosts/subnet. Say you're going with the first option. The last decimal in the address (0) has this notation. MMMM SHHH

  • M is Masked bits which can't change in network.
  • S is Subnet ID, which determines the subnet
  • H is Host ID, which determines the hosts.

Looking at some values with the mask

  • Mask 240 = 1111 0000
  • Binary 0 = 0000 0000
  • Binary 15 = 0000 1111
  • Binary 16 = 0001 0000

As we see, binary 16 would change a bit within the mask. Once a bit covered by the mask is changed, you're in a different network.

So the final breakdown would be

1) IP's in subnet-1 = 192.168.1.1 to 192.168.1.6 where 192.168.1.0 will be subnet id and 192.168.1.7 will be broadcast id.

2) IP's in subnet-2 = 192.168.1.9 to 192.168.1.14 where 192.168.1.8 will be subnet id and 192.168.1.15 will be broadcast id.

Once again, I don't expect much traction on an 8 year old post, but if someone happens across this like I did, I don't want them to get confused with the wrong information.

like image 35
Ed D Avatar answered Dec 19 '22 04:12

Ed D