I've been asked a number of times to explain whether devices on the same subnet or separate subnets.
In this example I've got two PCs.
The one on the left will be configured with an IP address of 10.1.1.1 and the
one on the right will be configured with an IP address of 10.1.2.2
So here's the question, Can these two hosts ping each other?
Are they in the same subnet?
It's a tricky question because you can't actually answer this question without knowing what the subnet
mask is.
You can't determine whether these two hosts on the same subnet
If you don't know what the subnet mask is. Now in this example rather than using a Windows PC, I'm using Cisco
routers as my PCs in my GNS3 topology.
Don't worry if you're not familiar with the Cisco CLI, I cover that in more detail in my CCNA course
but in this example what I'll firstly do is name the router on the left router 1 and the router on
the right I'll name as router 2 at the moment no IP addresses have been configured on the gigabit 0
interfaces of these routers so show IP interface brief.
Notice no IP address is configured on gigabit 00 on either router show IP interface gigabit 00 shows
us that to the interface is down Internet Protocol processing is disabled.
In other words IP doesn't work.
So what we need to do is go on to the gigabit 00 interface and no shut it that essentially enables the
interface
and then I need to configure an IP address on the interface.
So notice if I type IP address 10 1 1 1 and press enter, I'm told that that's an incomplete command.
The same is true on this side
I'll enable the interface.
And if I try and enable an IP address of 10 1 2 2, I'm told that that's an incomplete command.
You need to specify the subnet mask
so I'll do that on this side as well.
And notice now when I type show IP interface gigabit 0 0 we're told that the IP address configured
on this interface is 10.1.2.2 slash 24 on the side show IP interface gigabit 0 0.
We're told that the IP address is 10.1.1.1
This is using CIDR notation 24 equates to 24 binary ones which is the equivalent of doing it this way
in dotted decimal notation.
So do you say tomato or do you say tomato, do you say router or do you say router.
It's the same thing just a different way of phrasing it so 24 means 24 binary ones.
255 in decimal equates to 8 binary ones.
So this is 8 binary ones plus 8 binary ones plus 8 binary ones which equates to
24 binary ones.
So this is the same as this, what this is telling us is that the first 24 bits of the IP address is the
network portion.
In other words 255 first octet is network, 255 second octet is network, 255 third octet is network.
This is the network portion of the address.
This is the host portion based on the binary zeroes in the subnet mask, on this site
show run interface gigabit 00.
This is the network portion,
this is the host portion.
So when a device wants to ping another device it needs to determine whether the other device is in the
same subnet as itself the way it does that is it looks at the subnet mask and determines if the network
portion of the address is the same or if it's different if it's the same then the device will send out
an ARP.
Now if Ethernet is used the device will send out an ARP to work out which Mac address is associated with
the IP address.
If it's on a different subnet the device will typically forward the traffic to its default gateway.
Now in this example notice when we try and ping from router 1 to router 2 the ping doesn't work
because these two devices are in different subnets, can router 2 acting as PC 2 ping router 1 acting
as PC 1?
No, it can't, and that's because they're in different subnets we'll use the command de-bug IP packets on this
side and do the ping again.
We're told that the packets are unrouteable
the router doesn't know what to do with the packets.
In other words it doesn't know where to forward the packets.
However, if we change the subnet mask it's all configured the same IP address but use a slash 16 mask.
So show IP interface gigabit 00.
Notice that slash 16 and I'll just do that again.
So show IP interface gigabit 00 slash 16 mask show run interface gigabit 00.
Notice it's 255 255 0.0 and I'll do the same on this side IP address 10 1 1 1, 255 255 0.0 so show
IP interface gigabit 00 notice it say slash 16 mask
So again show IP interface gigabit 00 IP address on the site is 10 1 1 1 slash 16 show run interface gigabit
00 IP address looks like this.
So can these two devices now ping each other
you've got a lot of debugs there so let's turn off the debugging and try again.
Notice the ping succeeds on this side ping 10 1 2 2 ping succeeds.
Now debugging on a router just allows you to see what's going on in the background.
So it allows you to troubleshoot what's happening on your network.
So notice by just changing the subnet mask I was able to get these devices to ping each other because
I've now told them that they are in the same subnet
When traffic is sent and we're using the debug will be able to see what's going on.
So notice here we had one failure, one ping failed indicated by the dot and then four exclamation marks
told us that the pings succeeded.
We had an encapsulation failure firstly because the device had to send out an ARP to determine the remote
PCs Mac address.
And then once that was done a full packet was sent so after ARP resolution the packets were sent out
onto the gigabit 00 interface to the destination 10 1 2 2
because these two devices are now in the same subnet.
They can ping each other.
They know that they're in the same subnet because 10.1 the network portion is the same on both sides.
Hope you found this video useful if it was a benefit to you.
Please like it and please subscribe to my YouTube channel.
I wish you all the very best.