subnet mask behaviour

fonquefonque Member Posts: 92 ■■□□□□□□□□
This is probably a CCNA related question, but I came across this issue when troubleshooting a mismatched subnet mask at work this week.

example:

default-gateway: 192.168.1.1 255.255.255.0 (vlan 100)
my pc: 192.168.1.104 255.255.255.192 (vlan 100, based on cat4506 port config)

This was a manual configuration for testing connectivity for another device.
With my nic card on my laptop configure this way I was still able to ping the gateway and ping other hosts outside of my subnet. How is this possible if the gateway is in a different subnet that my laptop?

I copied and pasted the config from my laptop and the ping command results also.
I was kind of leaning toward arp timeouts playing a role here. But any insight would be helpful!
I program my heart to beat breakbeats and hum basslines in exhalation.... matter, verse, spirit

Comments

  • gojericho0gojericho0 Member Posts: 1,059 ■■■□□□□□□□
    It will work because they are in the same VLAN and the subnet of the PC falls within the subnet of the default gateway. If you change either the VLAN on one end, or change the IP of the PC to some thing outside the scope of 192.168.1.x\24 you will no longer be able to communicate with the gateway
  • fonquefonque Member Posts: 92 ■■□□□□□□□□
    i understand part of your point that the gateway can reach my pc,
    how is it possible for my pc to be able to reach the gateway, if the gateway is not in my pc's subnet?
    I program my heart to beat breakbeats and hum basslines in exhalation.... matter, verse, spirit
  • gojericho0gojericho0 Member Posts: 1,059 ■■■□□□□□□□
    ok, type step by step the ping process just from source (host) to destination (router) with your current configuration (you can assume arp is cache)
  • EdTheLadEdTheLad Member Posts: 2,111 ■■■■□□□□□□
    Your PC 192.168.1.104 255.255.255.192, so your pc is in subnet 192.168.1.64.It will be able to communicate with all devices within this subnet range.So that means you can communicate with ip addresses 192.168.1.65 -> 192.168.1.126 , the mask is used only to tell the pc which ip addresses it can communicate with.If you tried to communicate with 192.168.1.130, since this address does not fall within the local subnet, a default route must be used.

    The gateway is 192.168.1.1 255.255.255.0, which means the DG can directly communicate with hosts which have an ip address range 192.168.1.2 -> 192.168.1.254 .Since the pc falls within this range you can communicate with it.

    As you can see the mask doesnt not have to match on either end, the important thing is that both devices have an address range that overlap.
    Networking, sometimes i love it, mostly i hate it.Its all about the $$$$
  • Project2501Project2501 Member Posts: 60 ■■□□□□□□□□
    Something like this was brought up in my class the other day. I think it's called a multinet. Instead of a subnet which divides networks a multinet adds subnets together and reduces routing the size of the routing table. This helps with over network over heads I guess as the routing table is smaller.
    - Pete
  • EdTheLadEdTheLad Member Posts: 2,111 ■■■■□□□□□□
    Something like this was brought up in my class the other day. I think it's called a multinet. Instead of a subnet which divides networks a multinet adds subnets together and reduces routing the size of the routing table. This helps with over network over heads I guess as the routing table is smaller.

    You are probably referring to a supernet or a subnet with a shorter mask, whatever it is it is nothing to do with this question.This question is regarding forwarding, how a device can forward packets to other devices on the same broadcast domain with differing masks.
    This has nothing to do with routing, so best not confuse the OP.
    Networking, sometimes i love it, mostly i hate it.Its all about the $$$$
  • ixg123ixg123 Member Posts: 15 ■□□□□□□□□□
    Hmmm, I thought that I knew this stuff pretty well ... but I can't understand how/why this would work either!


    Completely ignoring the VLAN (as it is essentially representing a wire) leaves you with:

    default-gateway: 192.168.1.1 255.255.255.0
    pc: 192.168.1.104 255.255.255.192

    As Ed wrote
    Your PC 192.168.1.104 255.255.255.192, so your pc is in subnet 192.168.1.64.It will be able to communicate with all devices within this subnet range.So that means you can communicate with ip addresses 192.168.1.65 -> 192.168.1.126 , the mask is used only to tell the pc which ip addresses it can communicate with.If you tried to communicate with 192.168.1.130, since this address does not fall within the local subnet, a default route must be used.

    and I completely agree with this. So, going back to the very basics:
      1. For the PC to reach an IP address step 1 will be to AND each of the routing table entries with it's corresponding netmask, and compare it against the result of the destination IP address AND'd with the netmask. 2. If a match is found, and the entry represents a local interface, the IP packet can be forwarded at L2 and so an arp is performed for the destination MAC. 3. If a match is found and the entry represents a remote gateway, the process will be repeated in a search for the gateway address, and the packet forwarded at L3 via that gateway 4. If no match is found and a default gateway is defined, the process will again be repeated to find that default gateway MAC address, and the packet forwarded at L3 via the default gateway.[ 5. If no match is found, the packet will simply be discarded
    So .... if your default gateway is in a different network than your physical interface, how on earth would the ping packet make its way out of the network interface? How would it be able to determine the MAC address of the default gateway? Obviously I'm missing something here!!! icon_confused.gif
  • gojericho0gojericho0 Member Posts: 1,059 ■■■□□□□□□□
    You PC will check to see if the destination IP address is within the same network by using the SNM. If it is not, (as the case is here), the PC will still continue to create the packet and send it to the default gateway. As long as the PC as a default gateway entry it doesn't care if it is the same subnet or not it will still attempt to build and send the packet. The reason it is able to get to the router is because it falls within the routers subnet and they are part of the same broadcast domain. Think of it as the same process as using a default route if there is no matching route in a routing table.
  • geezergeezer Member Posts: 136
    I think the confusion is caused by the Default Gateway's mask. If there were four subnets in use as per the /26 mask then the hosts on the four subnets could only talk to eachother IF they are on the same subnet, else send to the default gateway whose mask encompasses all the subnets as it should or it would reject them otherwise if it too had a more restrictive mask.
    I used to be undecided but now I'm not so sure.

    There are only 10 types of people in the world: Those who understand binary, and those who don't!
  • cambeicambei Member Posts: 62 ■■■□□□□□□□
    I think it is clear that we all undertsand why the gateway allows this to happen (based on its subnet mask the host is valid within it's network). The confusing bit for me is that the PC does not seem to care that it's default gateway is not within it's subnet.

    I think as long as someone can confirm that that is what is happening then everyone should be able to understand.

    So my question is, does the PC try to send to the default gateway specified, regardless of the subnet mask used on the interface? If so, then I understand it. If not, I don't wanna know what's going on :P
  • gojericho0gojericho0 Member Posts: 1,059 ■■■□□□□□□□
    So my question is, does the PC try to send to the default gateway specified, regardless of the subnet mask used on the interface? If so, then I understand it. If not, I don't wanna know what's going on :P[/quote]

    It will only use the default gateway if the destination ip address falls outside the network block designated by the SNM
  • geezergeezer Member Posts: 136
    cambei wrote:
    ..,does the PC try to send to the default gateway specified, regardless of the subnet mask used on the interface? If so, then I understand it. If not, I don't wanna know what's going on :P

    Just like gojericho0 says. If the destination address was 10.1.1.1 then it is more obvious that this network is outside of the interface subnet in this example. The principle is the same because although the OP example is subnetted, the destination address is still outside the interface subnet range and hence sent to the router to parse its RIB for the destination network.
    I used to be undecided but now I'm not so sure.

    There are only 10 types of people in the world: Those who understand binary, and those who don't!
  • kpjunglekpjungle Member Posts: 426
    This is quite interesting. So, I understand that a host will try and use a default gateway if it needs to send data to something thats outside its own subnet (as per defined by the combination of its own ip address and SNM), but in this scenario, the gateway itself is not within the same subnet (GW Sn: 192.168.1.0/24, Host: 192.168.1.64/26) as the Host, seen from the hosts point of view, but it will still send a packet there?

    Bit confused by that myself :)
    Studying for CCNP (All done)
  • geezergeezer Member Posts: 136
    I have tried configuring my pc connecting to adsl router and if I change the subnet mask for the pc from /24 to /25 for example on the pc it doesn't see the router (gateway) anymore? Little confused myself.

    The OP must be due to VLAN operation.
    I used to be undecided but now I'm not so sure.

    There are only 10 types of people in the world: Those who understand binary, and those who don't!
  • kpjunglekpjungle Member Posts: 426
    geezer wrote:
    I have tried configuring my pc connecting to adsl router and if I change the subnet mask for the pc from /24 to /25 for example on the pc it doesn't see the router (gateway) anymore? Little confused myself.

    The OP must be due to VLAN operation.

    I did it in packet tracer, and the above behaviour is correct, I just dont know why :/
    Studying for CCNP (All done)
Sign In or Register to comment.