A subnet mask divides an IP address into network address and host address.
Correct. Apply the mask and you can see which part belongs to the network, and the reminder is the host address.
e.g. mask 255.255.255.0 and 1.2.3.4 would yield
IP: 00000001.00000010.00000011.0000100 (1.2.3.4. in binary)
Mask: 11111111.11111111.11111111.0000000 (mask in binary)
-----------------------------------
Net: 00000001.00000010.00000011.0 (1.2.3.0)
A network address always ends with a series of 0's like (mostly for
all subnets) such as 123.0.0.0, 123.45.0.0 and 123.45.67.0.
It often does, but part of that is habitual. I could use a netmask of 255.255.255.128 (Binary 11111111.11111111.11111111.1000000) to get smaller subnets. And 10.20.30.128 would be a network address, with 10.20.30.129 the first possible IP on it, 10.20.30.130 the second possible etc etc.
And for 10.20.30.0 to 10.20.30.127 the broadcast IP would be 10.20.30.127.
Routers act as intermediate stations to transfer data to the correct
network.
Correct. They look at their routing table. If know have a specific route then they apply it. If not they forward it to their standard place. This is where the default gateway comes in.
Now, I have the following questions- What actually is network address ?
Does it identify any real world host or Router?
i.e. are addresses like 123.0.0.0, 123.45.0.0 or 123.45.67.0 actually
assigned to any routers or hosts.
No. Network address are usually not assigned. They could be but then things would break down in most cases because the network address used to be used as the broadcast address before this got changed to the highest address in the network. Different implementations of IP stack would make using the network adress fun.
You might get away with it in very specific circumstances. E.g. on a specifc OS and with specific routers. But once you start to mix things, upgrade drivers or send things outside of your control (e.g. onto the Internet) you are going to have job security while debugging...
If they are assigned to routers then why is my local lan router
identified as 192.168.0.1 which is not a network address
That is merely a normal IP. 192.168.0.0/16 is usually used as a /24, with usuable IPs from 192.168.0.1 though 192.168.255.254 (65536-2 IPs). With the first IP usually reserved and the last IP reserved (as broadcast address).
Most SoHo setups take the RFC1918 range of 192.168.0.0/16, split in into 256 smaller subnets (/24) and assign the router the first or the last usable IP.
This makes a lot of sense when you design a network. One of the first things you need to plan the a way off the local network, and giving that the first IP got to be custom. But that is pure custom. Giving the router and IP of 192.168.1.42 is equally valid.
Suppose a request for 123.23.45.27 comes to a router, the router applies the subnet mask to it and suppose comes out with the network address as 123.23.0.0, so now it will check it's routing table for network address as 123.23.0.0 and refer to the corresponding routing table entry that is capable of handle this request and that router further handles the requests.
Are my following assumptions true?
A router finds the network address from the IP address and checks its
routing table.
True.
The routing table contains entries in the form of network address vs Router address and then a matched router address is picked up for forwarding the request.
Not sure about the versus. It contains network addresses. Briefly it does this:
- If the routers was the destination then the packet is handled up.
- If the router was not the destination then a router will check if it has a specific entry for a that host. Of it has it will forward it based on that.
- If the router was not the destination then a router will check if it has a specific entry for a network. If it has then it will forward it based on that.
- If the router was not the destination and it has neither of those then it will forward it to the default gateway as set on that router
All request's for IP address in the range 123.23.0.1 to 123.23.255.255
will be mapped to network address 123.23.0.0 and will be sent to the same
router for further routing.
Only for a /16. There are 30 possible network masks (excluding 0.0.0.0 and host-to-host specific ones) and only 3 of those end on the common round .0's
[sf] duplicate: What is the network address (x.x.x.0) used for?
– DavidPostill – 2016-04-13T15:39:53.167@DavidPostill Sorry to say but the question is much different. My main question is whether network address is actually assigned to any physical address or not. – Shivam Aggarwal – 2016-04-13T15:42:30.573
If you actually read the link you would see the answer is no, so it does answer both your questions. – DavidPostill – 2016-04-13T15:43:08.277
"are addresses like 123.0.0.0, 123.45.0.0 or 123.45.67.0 actually assigned to any routers or hosts." No. – DavidPostill – 2016-04-13T15:45:23.327
"If they are assigned to routers" they are not assigned to anything. – DavidPostill – 2016-04-13T15:45:51.840
"the first address in a subnet refers to the subnet itself and is used for routing purposes." x.x.x.0 is the first address in a subnet. – DavidPostill – 2016-04-13T15:46:56.017
Then what is the use of network address, why don't we directly give out router addresses ? – Shivam Aggarwal – 2016-04-13T15:47:43.537
Please read all of the answers in the link I already gave you. All your comments so far have been answered there. It says exactly what it is used for. – DavidPostill – 2016-04-13T15:51:56.977
I've added some edit's to my question. Please review. – Shivam Aggarwal – 2016-04-13T16:35:59.067
Much better duplicate target: How does IPv4 subnetting work?
– Dan Henderson – 2016-04-13T16:42:35.653A network address always ends with a series of 0's
. No, it does not. A network mask does, but there are way more masks than /8, /16 and /24. – Hennes – 2016-04-13T16:43:08.097@DanHenderson I've already read that beautiful answer :D. Can you please tell me if my assumptions in the edit are correct ? – Shivam Aggarwal – 2016-04-13T16:44:19.240
Also, what is a router address, did you mean a gateway? (which may or may not be a router). – Hennes – 2016-04-13T16:44:21.580
@Hennes No, I meant that is a router assigned the network address or is given a separate addresss – Shivam Aggarwal – 2016-04-13T16:45:18.137
The router is not assigned the network address. Nothing is assigned to that. The router usualy gets its own IP inside the network address range. – Hennes – 2016-04-13T16:52:27.257
Useful reeading: http://serverfault.com/questions/49765/how-does-ipv4-subnetting-work and this anwer where I started wrong and which had many edits: http://serverfault.com/questions/451238/why-cant-all-zeros-in-the-host-portion-of-ip-address-be-used-for-a-host/451248#451248
– Hennes – 2016-04-13T16:54:33.723@Hennes Got it thanks. Yep I've already read that beautiful answer. Can you please review my edit and tell me it I'm correct. – Shivam Aggarwal – 2016-04-13T16:55:23.363
2@Shivamaggarwal Your first assumption is correct. Your second and third assumptions may not be quite phrased exactly right, but they lead me to believe that you (mostly) understand subnetting correctly, even if you're not necessarily explaining it well. (If you said those 3 sentences to someone who doesn't understand IPv4 subnetting, I think they could still misinterpret what you said and reach an incorrect conclusion.) – Dan Henderson – 2016-04-13T16:58:26.187
@DanHenderson Great, you understood it pretty well. I'd be really glad if you could please add, remove or modify any of my assumptions for a better understanding. Thanks :D. – Shivam Aggarwal – 2016-04-13T17:02:54.640
1
@Shivamaggarwal I could go into more detail, but it would have to be in an answer, it would take me all day, and in the end it would really just be a duplication of all the same information you can already find in http://serverfault.com/q/49765/305280. But I can quickly tell you that
– Dan Henderson – 2016-04-13T18:45:21.520A network address always ends with a series of 0's
is definitely incorrect. For example, you can have a 26-bit subnet mask, which for192.168.1.200
will yield a network address of192.168.1.192
.