IP Address of Router

Started by tahir4awan, April 20, 2021, 04:32:47 PM

Previous topic - Next topic

tahir4awan

Hello,

I have confusion about Host addresses. For example an IP address 192.168.0.1 with subnet make 255.255.255.0 have 256 host addresses and from these only 254 are usable. It is cleared that 192.168.0.255 is a broadcast address. But what is network address and default gateway? Is 192.168.0.0 but where do we use this address? Default gateway as we know is 192.168.0.1 but it must not be one it could be any Ip address.

Normally 192.168.0 is network part, but why we say 192.168.0.0 is  network address?

If 192.168.0.0, 192.168.0.1 and 192.168.0.255 are reserved then why do we say 254 hosts are usable?

Please help..


Thanks

Dieselboy

#1
Hello and welcome :)

You are all correct except about the "network address" part. It would help if we know the definition of what is a network address.

A network address is where all of the bits in the host portion are zero. The key points here: Host portion are zero.

To understand this, you should start by writing out your subnets, masks and hosts IP addresses in binary. This will get easier the more you do it and I recommend doing it as much as you can.

Let's take your subnet of 192.168.0.0 with mask 255.255.255.0. Now, the mask is the import thing here. Again, it's in binary. 255.255.255.0 is a /24 mask. This means that the first 24 bits are turned ON and this signifies the network part. The bits which are OFF signify the host part. In binary it's written like this:

Quote11111111.11111111.11111111.00000000

Now that doesnt make much sense on it's own. It helps if we also write out the IP address underneath it. I've added green colour to signify HOST and red for NETWORK part:

Quote
11111111.11111111.11111111.00000000
11000000.10101000.00000000.00000000

Another way of saying it is, the network MASK allows us to draw a separation line into the IP address which separates host portion of IP addresses from network portion of IP addresses.

11111111 = 255 because each bit represents a number. Counting from right to left each bit has a value. We add these values together for all of the bits which are turned on.The first bit has a value of 1. The second has a value of 2, the next has a value of 4 and this doubles each time until the last bit in the octet has a value of 128. So it goes: 1, 2, 4, 8, 16, 32, 64, 128. But remember it counts from right to left, so in actual fact the 1st bit has "128" and the 8th bit has a value of "1". A bit confusing but this is just something to remember. Like this:

128  64  32  16  8  4  2  1.


With a /24 subnet mask, it's quick and easy to tell which part is the network because the 24th bit is clearly the first three octets, leaving the last octet free for numbers 0-255 (or hosts 1-254). Remember, network address is where all of the host bits are OFF (or rather zero). So if you look at the above IP and mask, any time there is a 1 anywhere in the host portion, it means it's a host IP address. IF all digits are 0 then it's a network address and if all are 1 in the host part then it's a broadcast address.

Again this is simple to look at when it's a /24. But what if it's not a /24 but it is instead a /29? We will keep the same subnet address of 192.168.0.0 but use a /29 mask instead (255.255.255.248)

Quote
11111111.11111111.11111111.11111000
11000000.10101000.00000000.00000000

It should be clear from the above that the line which separates the host from the network portion has moved further to the right side because of the subnet mask. With a /29 mask we have only 3 host bits to play with. With that subnet address if 192.168.0.0 we can have hosts from 192.168.0.1 to 192.168.0.6 and the broadcast address is 192.168.0.7. The broadcast is ".7" because there are 3 host bits and they are all turned on. the last 3 bits in the octet add up to make 7. 4 + 2 + 1 = 7.

Another example of a network address could be 192.168.0.248/29. The same /29 mask is used but we basically have a different network ID. Drawing it out looks like this:

Quote
11111111.11111111.11111111.11111000
11000000.10101000.00000000.11111000

Again, notice that we still have all zero in the host portion and this is what signifies the network address. Even though the IP address is 192.168.0.248 which looks like a host address, but it is indeed a network address because of the /29 subnet mask applied to it. The subnet mask is the important thing to note when finding the network address.

I hope this helps :)

Otanx

To add to Dieselboy's post. The gateway is not reserved. It is just another host, and you don't need one if you don't need to talk to other networks. You don't even need to use .1 as the IP. You can use any avalible host address you want.

-Otanx

icecream-guy

the network address is used in routing, when we tell Router "to get to network xxx"  "use next hop of yyy".  where yyy is IP address on next hop in a path to the destination network.

route 192.168.1.0 255.255.255.0  192.168.2.1

here we tell the router how to get to the network (specifically 192.168.1.0/24 network) by using next-hop IP of 192.168.2.1
:professorcat:

My Moral Fibers have been cut.

heath

To echo Otanx's comment, the gateway being assigned the .1 address is just convention, but can be any useable address.  During my brief time in federal government, it was common for .254 to be the gateway address in a /24 network.