1

enter image description here

In the diagram above, when two PCs belonging to same network like 192.168.1.10 /24 and 192.168.1.20 /24 but to diffrent Vlans, I suppose they cant't communicate each other.

Now, I wonder how both PCs know which VLAN the other PC belongs to?

When frames arrive at the trunk port between the switch and the router, VLAN tagg is inserted into frames, so that the switch and the router can tell which VLAN the frame belongs to.

At the access port, does same thing happen like at the trunk port?

1

In the diagram above, when two PCs belonging to same network like 192.168.1.10 /24 and 192.168.1.20 /24 but to diffrent Vlans, I suppose they cant't communicate each other.

That is correct.

I wonder how both PCs know which VLAN the other PC belongs to?

They don't. Normal hosts have no knowledge of VLANs.

The switch in between does as it's configured that way (for layer 2), as is the router (for layer 3).

When PC1 sends a packet to the PC2 it uses the router as gateway. The IP packet is addressed for PC2 but the encapsulating frame is addressed for the gateway. It travels untagged to the switch, gets tagged for VLAN10 and is forwarded to the router.

The router extracts the packet, decides that goes to VLAN20, encapsulates it in a frame addressed to PC2, tags it, and sends it towards the switch. The switch decides which port is goes to, removes the tag and forwards it to PC2.

When frames arrive at the trunk port between the switch and the router, VLAN tagg is inserted into frames, so that the switch and the router can tell which VLAN the frame belongs to.

A tag is used while the frame is on the trunk. That tag tells the switch (or the router) which VLAN the frame belongs to.

The router uses its routing table to decide which subinterface it uses towards the destination IP. Each subinterface is connected to one of the VLANs and the transport frame is tagged for that VLAN.

In the other direction, the switch tags each frame according to the ingress port's untagged (native) VLAN.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.