Ping two computers within same network but different subnet mask

#1

if one pc has 1.1.1.1 255.0.0.0 and second pc has 1.1.1.2 255.255.255.0. why both are ping together. because they have different subnet mask.
and how we assign class A with 255.255.255.0 subnet mask.

2 Likes

#2

Because the two addresses have the same IP range with different and classfull subnet mask.
Then 1.1.1.1 /8 and 1.1.1.2 /24 or 1.1.1.2/25 until 1.1.1.2/30 is in the range covered by /24

2 Likes

#3

i think you know the anding process.
so when you are trying to ping from 1.1.1.1/8 it means the source host will only match the firs octet of your ip. so in this case destination ip is 1.1.1.2/24.
so in this case source host will find that the “source ip” and and “destination ip” are in the same subnet. by doing ANDING Process.
ANDING Process of “host1 ip” with “host1 subnet mask”::
Host1
IP : 1.1.1.1
Subnet Mask: 255.0.0.0
in ANDING Process there is some rules
A B Result
1 0 0
1 1 1
0 1 0
so if we do ANDING with Host1 IP with Subnet Mask it will be
IP: 00000001:00000001:00000001:00000001
Subnet: 111111111:00000000:00000000:00000000
Result: 00000001:00000000:00000000:00000000
so the network is 1.0.0.0

ANDING Process of “destination Ip” and “subnet mask of host1”
IP: 000000001:00000001:00000001:00000010
SUBNET: 1111111111:00000000:00000000:00000000
RESULT: 1.0.0.0
Now you will find that Host1 network and host2 network is in same subnet.
so host1 will send data to host2.
now the destination host will read the packet and will again check for ip add and will ensure that whatever packet he has received is this for him or not. so again destination host wil do same anding process
his own ip address with his own subnet mask and will find the network part so in that case network will be (1.1.1.0) and will do anding process with sender ip address with subnet mask and the network will be (1.1.1.0).
so host2 also found that “yes this packet is for me”
now he will send echo reply to Host2 as they are in same Subnet.
that’s why instead of having different Subnet Mask they are pinging.

1 Like