Seek some advice on how to properly configure 2 routers to connect with a layer 2 switch in-between.
In the picture below, i have 4 routers connecting through a layer 2 switch.
Here are my configurations:
I am unable to ping from Router0 to Router 1 nor Router2 to Router3. However, when i change the configs on the switchport to "switchport mode trunk", the ping worked. Why? It wouldnt be feasible for me to configure trunk on the switch as i would want only traffic from the respective vlans to communicate.
I dont thnk u can give "encapsulation dot1q" command on a router interface. That command works only if we create sub interfaces on a router and u dont have to configure that for two devices in the same VLAN to communicate. Rest of the configuration looks fine. Ping should work.
Yes I did the commands on my router in the sub-interface.
int fa0/0.10 and int fa0/0.50 respectively for the different vlans.
Still wouldnt work unless i configure trunk on the switchport.
U dont have to create any sub interfaces. Just assign the IP addresses to the respective interfaces and the ping should work.
However, when i change the configs on the switchport to "switchport mode trunk", the ping worked. Why?
Trunks carry traffic from all VLANs (that's why ping works)
While Access mode only passes traffic for the vlan specified on the port.
the router subinterface is doing dot1q and is waiting for tagged traffic but the switch is in access mode so it doesn't tag traffic so it can't work.
Directly assigning IP address to Router interfaces without encapsulation dot1q does work.
Another way which i just found out that allows tagging of traffic based on vlan at the router is to do the following:
You are not being consistent in your configuration. You must choose to either use trunk links or access links.
By using SW(c-if)#switchport mode access you are telling the switch to send normal untagged Ethernet frames on the link, and to tag incoming frames with a 802.1q header to be sent on trunk links or processed by other switchports belonging to the same VLAN.
if u are using dot1q encapsulation on router with sub interface then the other end of switch the configuration should be trunk,if u configure it as access port it will not understand tagged frames.
you can do this setup in two ways.
1.just give ip address to router without creating subinterfaces with switch configuration same as above.
2.creating subinterfaces on routers,then you should configure switch ports as trunk.so you want connectivity between routers in this setup,configure the 4 ports as trunks.