cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
127519
Views
25
Helpful
4
Replies

Switch port mode to connect a router

ADAman
Level 1
Level 1

I am just wondering which mode to set the switchport that is connected to a router.

I assume the cable connecting the router is plugged into a port in trunk mode (for all the defined VLANS)? Then I make SVIs with gateways  for the VLANs pointing to routing-interfaces in the router?

So in this way, if a neighboring switch does not know how to route a packet to a unknown IP-address, the packet is sent over the trunk to the other switch. Here the appropriate VLAN SVI is sending the packet to the appropriate router interface. Is this correct or nearly correct?

1 Accepted Solution

Accepted Solutions

answanso
Cisco Employee
Cisco Employee

Hi Atle,

You can connect either a trunk port or an access port to a router. If you choose to use an access port, the router will form an adjacency only over the VLAN defined in that access port. If you choose a trunk port, you can use dot1q encapsulation on subinterfaces to form adjacencies over multiple VLANs. If you using a trunk you would do this type of configuration:

On the switch:

interface gi1/0/1

switchport mode trunk

switchport trunk encapsulation dot1q

switchport trunk allowed vlan a-c

On the router

interface gi0/0.a

encapsulation dot1q a

ip address x.x.x.x y.y.y.y

!

interface gi0/0.b

encapsulation dot1q b

ip address v.v.v.v y.y.y.y

!

interface gi0/0.c

encapsulation dot1q c

ip address z.z.z.z y.y.y.y

Here is a good tutorial on it:

http://www.howtonetwork.net/public/708.cfm

Cisco documentation on the feature:

http://www.cisco.com/en/US/docs/ios/12_0t/12_0t1/feature/guide/8021Q.html

To answer your question, you can use the router as the default gateway for hosts. In the that case it would not be required to have an SVI on the switch except for MGMT purposes. Traffic from hosts would take the L2 path to the router and then the router would make the next forwarding decision for the packet. If you had two routers you could do a trunk to both routers and run a FHRP between them for redundancy.

HTH

Anthony

View solution in original post

4 Replies 4

answanso
Cisco Employee
Cisco Employee

Hi Atle,

You can connect either a trunk port or an access port to a router. If you choose to use an access port, the router will form an adjacency only over the VLAN defined in that access port. If you choose a trunk port, you can use dot1q encapsulation on subinterfaces to form adjacencies over multiple VLANs. If you using a trunk you would do this type of configuration:

On the switch:

interface gi1/0/1

switchport mode trunk

switchport trunk encapsulation dot1q

switchport trunk allowed vlan a-c

On the router

interface gi0/0.a

encapsulation dot1q a

ip address x.x.x.x y.y.y.y

!

interface gi0/0.b

encapsulation dot1q b

ip address v.v.v.v y.y.y.y

!

interface gi0/0.c

encapsulation dot1q c

ip address z.z.z.z y.y.y.y

Here is a good tutorial on it:

http://www.howtonetwork.net/public/708.cfm

Cisco documentation on the feature:

http://www.cisco.com/en/US/docs/ios/12_0t/12_0t1/feature/guide/8021Q.html

To answer your question, you can use the router as the default gateway for hosts. In the that case it would not be required to have an SVI on the switch except for MGMT purposes. Traffic from hosts would take the L2 path to the router and then the router would make the next forwarding decision for the packet. If you had two routers you could do a trunk to both routers and run a FHRP between them for redundancy.

HTH

Anthony

Thanks a lot! This was very clear.

hi @answanso thank you for your reply. I have a question. What if we have a single VLAN (suppose vlan 10) and 4 PCs are part of it. Do we need to configure the switchport (which is connected to Router) as trunk or as access port? how does this work? could you please explain? thank you . 

Joseph W. Doherty
Hall of Fame
Hall of Fame

Just to add, if the "switch" is a L3 switch, you also could use a "routed port" or still use an access or trunk port, as described in an earlier reply.

Also BTW, keep in mind, that many routers have much, much lessor routing performance than a L3 switch.  So, for LAN routing, you often want to avoid routing on a router.  However, as WAN connections often provide less bandwidth than LAN connections, a router can be okay, and may be needed for other router features not typically found on switches.

Review Cisco Networking for a $25 gift card