Networks vs Subnets

Can a computer with a class C IP address similar to 192.168.0.1 and a subnet mask of 255.255.255.0 exchange and exchange resources with another computer with IP 192.168.1.1 and the same subnet mask of 255.255.255.0? I ask about it because the first 3 octets in this case tell us that these IP addresses work on different networks (network 192.168.0.0 and network 192.168.1.0). Also, does “network” mean the same as “subnet” (or “subnet”) in this context? Thanks!

+4
source share
3 answers

To fully understand how computer networks work, you need to look at the OSI model (or in practice, the TCP / IP or DoD model). For your question, you first need to look at three levels: physical, data channel and network.

The physical connection is self-evident and is a direct connection through some medium (copper, glass, air).

When host A tries to send a packet to host B, the first thing it will do is look at the recipient’s IP address and, based on its own IP configuration, determine if host B is on the same subnet as host A. This has already been explained to you Eugene Reik: the subnet mask bit is used to mask the bits of the IP address (logical AND operation). Now we have two cases:

  • Host A and B are on the same subnet.
  • Host A and B are not on the same subnet.

It should be noted that at level 2, which network adapters use to send and receive frames, there are no IP addresses (which are present at level 3), but instead, communication between devices is performed using MAC addresses. Because of this, a host can only communicate directly with hosts on its subnet (1st scenario). To send the frame host, the MAC address of host B is required. Thus, host A first looks for the MAC address mapped to the IP address of host B in its ARP table. If he cannot find it, he sends a broadcast ARP request with the request of the entire host on the subnet that has a specific IP address. If he receives a response, he adds the MAC address of the host to which he received a response and creates a packet with the destination MAC address of this host and the IP address of this host.

If both hosts are not on the same subnet (second scenario), the packet is sent to the default gateway, which is responsible for finding the route to the destination. The key point here is that even if the destination MAC address in this case is the MAC address of the router (default gateway), the destination IP address is still the IP address of host B, as in the first scenario. As the packet moves from the router to the router, the source and destination MAC addresses will change because they are locally significant, but the source and destination IP addresses will remain unchanged. Thus, each layer provides a service (so to speak) to the upper levels, and the upper layers use it transparently, without requiring to know what happens below.

So you have:

1st scenario.

---------------- L2: Src MAC: host A Dst MAC: host B ---------------- L3: Src IP: host A Dst IP: host B ---------------- 

Second scenario:

 ---------------- L2: Src MAC: host A Dst MAC: router ---------------- L3: Src IP: host A Dst IP: host B ---------------- 

To summarize (@Eugen Rieck's answer already gave you):

Two hosts that are not on the same subnet as in your example (192.168.0.1/24 and 192.168.1.1/24) will not be able to communicate at level 2, and for this you will need a device with L3 support, such as a router, act as the default gateway and route traffic between two networks (broadcast domains) for a layer 3 connection.

+11
source

Yes and no:

Yes: these two computers can communicate if there is a (correctly configured) router between them, and both sides are aware of this.

Not. These two computers cannot exchange data if they are simply connected to the same disconnected switch.

Rule of thumb: IP & SNM must be the same for all participants to allow direct communication.

+3
source

You will need to change the subnet mask to 255.255.254.0 or use the router or layer-3 switch for communication.

Network usually means the entire network that you are accessing, and subnet refers to a specific separate part. However, the terminology is pretty loose.

+2
source

Source: https://habr.com/ru/post/1494391/


All Articles