Understanding Subnet Masks and IP Addresses in Computer Networking

  • Thread starter Stephanus
  • Start date
In summary, subnet masks and IP addresses play crucial roles in computer networking. A subnet mask is a 32-bit number that is used to divide an IP address into network and host portions. It allows for the identification of specific networks and devices within a larger network. IP addresses, on the other hand, are unique numerical identifiers assigned to devices connected to a network. They enable devices to communicate with each other over a network. Understanding how to properly use and configure subnet masks and IP addresses is essential for efficient and secure communication in a network.
  • #1
Stephanus
1,316
104
Dear PF Forum,
I want to understand computer networking.
There's a problem that I'd like to know the answer. This problem might not come out in day to day practice, but by having the answer of this problem, I hope I can, at least, understand how router works.

Consider there are 3 computer. A, B and C.
There IP address and subnet mask are.
A: 192.168.1.1, mask: 255.255.0.0, so its network address is: 192.168.0.0
B: 192.168.1.2, mask: 255.255.255.0, so its network address is: 192.168.1.0
C: 192.168.2.3, mask: 255.255.255.0, so its network address is: 192.168.2.0

My question is.
1. Can A ping B?
My reasoning is this.
A will see that B(IP) AND A(Mask) = A(IP) AND A(Mask) = 192.168.0.0
So basically A will consider B in the same network.
And so does B will see that A is at the same network. A(IP) AND B(Mask) = 192.168.1.0

2. Can B ping A?

3. Can A ping C?
My reasoning is this.
A will see that C(IP) AND A(Mask) = A(IP) AND A(Mask) = 192.168.0.0
So basically A will consider C in the same network.
Although C will see that A is at different network. A(IP) and C(Mask) = 192.168.1.0

Thank you very much.
 
Computer science news on Phys.org
  • #3
Haven't pinged an internal IP on my network before (only the likes of websites). However trying now it appears you can, so I've learned something new today!
 
  • Like
Likes Stephanus
  • #4
StevieTNZ said:
Haven't pinged an internal IP on my network before (only the likes of websites). However trying now it appears you can, so I've learned something new today!
Yeah, it's like reverse engineering. I have a theory, why it can/can't connect.
If it can then... (this is the theory)
If it cannot then...(this is the other theory).
I should have tried it in my office.
Thanks anyway.
 
  • #5
Simply put in my opinion,
1. Yes
2. Yes
3. No
Explanation: 1 and 2 share the same network 192.168.1.x whereas 3 stays in a different one 192.168.2.x
 
  • #6
Pepper Mint said:
Explanation: 1 and 2 share the same network 192.168.1.x whereas 3 stays in a different one 192.168.2.x
A: 192.168.1.1, mask: 255.255.0.0, so its network address is: 192.168.0.0
B: 192.168.1.2, mask: 255.255.255.0, so its network address is: 192.168.1.0

The network address for
A: 192.168.0.0
B: 192.168.1.0
Different, are you sure?
 
  • #7
Stephanus said:
A: 192.168.1.1, mask: 255.255.0.0, so its network address is: 192.168.0.0
B: 192.168.1.2, mask: 255.255.255.0, so its network address is: 192.168.1.0

The network address for
A: 192.168.0.0
B: 192.168.1.0
Different, are you sure?
Let's do a simple experiment to verify this.
Use 2 routers (uh oh what is your pronunciation of this word ? mine is /rounter/ :oldbiggrin:) and nat your network with them, one is 192.168.0.x and the other 192.168.1.x . And try pinging a computer in one network to another in the other network. The pinging would fail. I am sure about this. My ways to answer questions might make readers think I seem unsure about what I say but that is who I am, a humble person with a true sense to pursue beauty to its lair. :blushing:
 
  • Like
Likes Stephanus
  • #8
Good idea, I'll try it. Thanks.
 
  • #9
The network mask only shows the IP handler which hosts (IP dialect for computer) it can reach without going through a router. Thus:

Assume that your PC has the IP address 192.168.1.17 with a subnet mask of 255.255.255.0 and a default gateway of 192.168.1.1 (this is old-fashioned IP dialect for router). Then
  • If you want to connect to 192.168.1.33, the IP handler uses the subnet mask and discovers that both hosts are on the same subnet. It then establishes a connection directly with 192.168.1.33 without bothering the router at all.
  • If you want to connect to 74.86.200.109 (the IP address of this forum), the IP handler uses the subnet mask and discovers that the destination host is not on the same subnet. It then sends the connection request (with the destination IP address) to the router, leaving the problem of locating the destination host to the Internet collection of routers. The routers have their own set of protocols between them (OSPF (https://en.wikipedia.org/wiki/Open_Shortest_Path_First), BGP (https://en.wikipedia.org/wiki/Border_Gateway_Protocol)) to help them find their way to the destination.
 
  • #10
Svein said:
The network mask only shows the IP handler which hosts (IP dialect for computer) it can reach without going through a router. Thus:

Assume that your PC has the IP address 192.168.1.17 with a subnet mask of 255.255.255.0 and a default gateway of 192.168.1.1 (this is old-fashioned IP dialect for router). Then...
Thanks, may I discuss further?
* If you want to connect to 192.168.1.33, the IP handler uses the subnet mask and discovers that ...
192.168.1.17 and 255.255.255.0 = 192.168.1.0
192.168.1.33 and 255.255.255.0 = 192.168.1.0
both hosts are on the same subnet. It then establishes a connection directly with 192.168.1.33 without bothering the router at all.


* If you want to connect to 74.86.200.109 (the IP address of this forum), the IP handler uses the subnet mask and discovers that...
192.168.1.17 and 255.255.255.0 = 192.168.1.0
74.86.200.109 and 255.255.255.0 = 74.86.200.0

the destination host is not on the same subnet. It then...

Ok, but what about this.
My IP 192.168.1.17, mask: 255.255.0.0
Target. 192.168.2.18, mask 255.255.255.0
Can I ping to target without?
Can I ping to target even with router?
Thanks.
And thanks for the wiki links.
 
  • #11
Stephanus said:
Ok, but what about this.
My IP 192.168.1.17, mask: 255.255.0.0
Target. 192.168.2.18, mask 255.255.255.0
Can I ping to target without?
Can I ping to target even with router?
Your subnet mask is the only one that matters. You promise the IP handler that you can access the complete 192.168.0.0.network directly. If you have made a false promise, change your subnet mask (255.255.252.0 will promise access to 192.168.1.0, 192.168.2.0 and 192.168.3.0).

As you state it, the IP handler will try to connect directly. Since you have promised the IP layer that you are able to connect directly, it will not try to go through a router.
 
  • #12
Stephanus, do you realize you are asking us "what will happen if I have a misconfigured network?"?

The subnet mask is a property of the network, not any PC on it. If you misconfigure the PCs (e.g. A is reachable from B and B is not reachable from A) you should expect problems.
 
  • Like
Likes CalcNerd
  • #13
Some additional information:

Private IPv4 address spaces (https://en.wikipedia.org/wiki/Private_network)
The Internet Engineering Task Force (IETF) has directed the Internet Assigned Numbers Authority (IANA) to reserve the following IPv4 address ranges for private networks, as published in RFC 1918 (https://tools.ietf.org/html/rfc1918):
  • 10.0.0.0 - 10.255.255.255
  • 172.16.0.0 - 172.31.255.255
  • 192.168.0.0 - 192.168.255.255
This means that your 192.168.1.17 address is not allowed on the Internet. Your (modern) router will map that address onto a valid Internet address.
 
  • #14
Thank you staffs/mentors for you advice.
I think I have to try it myself. I'm in a process of learning networking here.
Code:
A Ping to B:All ping to 192.168.1.223

Trial 1
A: 192.168.2.222,  255.255.255.0
B: 192.168.1.223,  255.255.0.0
Result: Destination host unreachable

Trial 2
A: 192.168.1.222,  255.255.255.0
B: 192.168.1.223,  255.255.0.0
Result: Success

Trial 3
A: 192.168.1.222,  255.255.0.0
B: 192.168.1.223,  255.255.255.0
Result: Success

Trial 4
A: 192.168.2.222,  255.255.0.0
B: 192.168.1.223,  255.255.255.0
Result: Reguest time out

--------------------------------------
ping Computer_B_Name: could not find host
pinging to computer name will yield 
"Could not find host", 
even if pinging to IP address is successful

@Svein, I'll rearrange your reply without quote tag.
- Your subnet mask is the only one that matters. You promise the IP handler that you can access the complete 192.168.0.0.network directly.
Yes
- If you have made a false promise, change your subnet mask (255.255.252.0 will promise access to 192.168.1.0, 192.168.2.0 and 192.168.3.0).
No false promise. I just what to check that my promise is to 192.168.0.0, and I want to ping to a computer that promises to 192.168.1.0
I want to see if it works.
See trial 3 and 4 above.

- As you state it, the IP handler will try to connect directly. Since you have promised the IP layer that you are able to connect directly, it will not try to go through a router.

Yes, but my promise should somehow meet the other computer promise (?)
In class C
192.168.1.222 can ping to 192.168.1.223
192.168.2.222 cannot ping to 192.168.1.223

In class B
192.168.2.222 can ping to 192.168.1.223

But
192.168.2.222 (B) cannot ping to 192.168.1.223 (C)
192.168.1.222 (B) can ping to 192.168.1.223 (C)

I'm new in networking here.

Vanadium 50 said:
Stephanus, do you realize you are asking us "what will happen if I have a misconfigured network?"?
Misconfiugre? Well..., I did it intentionally. I just want to know the effect.
(Now I have reset my IP to 10.1.xxx.xxx back, or I won't be able to answer this thread :smile:)

Vanadium 50 said:
The subnet mask is a property of the network, not any PC on it. If you misconfigure the PCs (e.g. A is reachable from B and B is not reachable from A) you should expect problems.
That's right! And I don't want to set my network that way. I just want to understand about mask and router and IP. It turns out that network mask also plays an important role here, not just router. Less than a month ago I just understand this. Before that, I think it only takes IP to do this networking. Thanks for the tips.

Svein said:
Some additional information:
Private IPv4 address spaces (https://en.wikipedia.org/wiki/Private_network)
The Internet Engineering Task Force (IETF) has directed the Internet Assigned Numbers Authority (IANA) to reserve the following IPv4 address ranges for private networks, as published in RFC 1918 (https://tools.ietf.org/html/rfc1918):
Thanks for the links.

Svein said:
  • 10.0.0.0 - 10.255.255.255, 16,777,716 - 2 addresses
  • 172.16.0.0 - 172.31.255.255, 220 = ... 1,048,576 - 2 addresses
  • 192.168.0.0 - 192.168.255.255, 65,536 - 2 addresses
Not trying to show off here, but most computer programmers will remember 224, 220, 216, 210, 28 .. 20. :smile:

Svein said:
This means that your 192.168.1.17 address is not allowed on the Internet. Your (modern) router will map that address onto a valid Internet address.
Of course not. As someone working in a supermarket, it's just like item barcode.
https://en.wikipedia.org/wiki/List_of_GS1_country_codes
100: USA
300: France
49: Japan
890: India
899: Indonesia, etc...
But what if your company intends to create barcode for internal use. What kind of barcode number that will not collide other international barcode. So we have to use local barcode number: 200.
It's just like IP address that you have given us.
10.x.x.x,
172.16.x.x to 172.31.x.x,
192.168.x.x.
@Svein Thanks for the answer.
 
  • #15
Just a tip: If you have several computers on your local area network, use a DHCP server to distribute correct IP information to all computers (and pads and smartphones). You give the DHCP server an address range to administer and specify the netmask and "default gateway".

If you want to know more about DHCP, check out https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol.
 
  • Like
Likes Stephanus
  • #16
Svein said:
Just a tip: If you have several computers on your local area network, use a DHCP server to distribute correct IP information to all computers (and pads and smartphones). You give the DHCP server an address range to administer and specify the netmask and "default gateway".

If you want to know more about DHCP, check out https://en.wikipedia.org/wiki/Dynamic_Host_Configuration_Protocol.
DHCP? Sure why not. I'm new in computer networking I just learn now.

Perhaps the reason I create this thread was I needed confirmation.
I read this two rules in computer networking.

Rule A: Network address is IP Address masked by mask bit.
Netwok Address = IP Address and Subnet Mask.
For example
IP: 192.168.1.15
Mask: 255.255.255.0
So network address is 192.168.1.0

Rule B: Only computers with the same network address can communicate without router.

So according to Rule A.
Computer A with
IP: 192.168.1.222, Mask: 255.255.0.0
will see that Computer B with IP: 192.168.2.223, is in the same network address/range.

But according computer B.
IP: 192.168.2.223, mask: 255.255.255.0
will see that computer A is in different network address.

Some literature in the internet don't address this issue.
But as I tried it myself yesterday, I found the answer, but still no network rule that states it can/cannot be done.

Thanks anyway @Svein
 
  • #17
Stephanus said:
Some literature in the internet don't address this issue.

That's because you are [still] asking about the properties of a misconfigured network. A subnet has a range if IP addresses, and every computer on it needs to have the same range. If you tell one computer the range is 192,168.0-255.0-255 and another something different, like 192.168.2.0-255, you do not have the same range, your network is misconfigured.
 
  • Like
Likes vk6kro, Stephanus and Pepper Mint

FAQ: Understanding Subnet Masks and IP Addresses in Computer Networking

What is a subnet mask?

A subnet mask is a 32-bit number used in computer networking to separate the network and host parts of an IP address. It helps determine which part of the IP address identifies the network and which part identifies the specific device on the network.

What is an IP address?

An IP address is a unique numerical label assigned to each device connected to a network. It identifies the device and allows it to communicate with other devices on the network. IP addresses are essential for internet communication.

How do subnet masks and IP addresses work together?

Subnet masks and IP addresses work together to determine the network and host portions of an IP address. The subnet mask is used to compare against the IP address to determine which part identifies the network and which part identifies the device.

Why are subnet masks and IP addresses important?

Subnet masks and IP addresses are important because they allow devices to communicate with each other on a network. They also help with network management and security by segmenting a large network into smaller, more manageable subnets.

What is the difference between IPv4 and IPv6?

IPv4 (Internet Protocol version 4) and IPv6 (Internet Protocol version 6) are two different versions of the IP address system. IPv4 uses a 32-bit address format, while IPv6 uses a 128-bit address format. This allows for a much larger number of unique addresses in IPv6, which is necessary due to the increasing number of devices connected to the internet.

Similar threads

Back
Top