We help IT Professionals succeed at work.

Cisco sub interface and vlans

solidrumor
solidrumor used Ask the Experts™
on
My 2821 routers gi0/1 interface is attached to a 2948G switch. All hosts on the switch belong to the default vlan (vlan1). I want to add three additional subnets. I can add sub interfaces to the gi0/1 router interface but do I need to create new vlans on the switch? If I did not create  new vlans on the switch and plugged a host from the new subnet into the switch would it be able to communicate with the rest of the network? My switch is runnning catos 8.3 would you please provide config examples to setup a vlan on this model switch.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Head of IT Security Division
Top Expert 2010
Commented:
router or switch config needed?
Commented:
You would need to create a VLAN for each subnet you want on your switch. The router would need to be connected to the switch on a trunk port and the router's ethernet interface would need sub interface for each subnet.

For example:

VLAN 2 - 192.168.2.0 255.255.255.0
VLAN 3 - 192.168.3.0 255.255.255.0
VLAN 4 - 192.168.4.0 255.255.255.0

Router(config)# interface Fa0/1.2
Router(config-if)#encap dot1q 2 native
Router(config-if)#ip add 192.168.2.1 255.255.255.0
Router(config)# interface Fa0/1.3
Router(config-if)#encap dot1q 3
Router(config-if)#ip add 192.168.3.1 255.255.255.0
Router(config)# interface Fa0/1.4
Router(config-if)#encap dot1q 4
Router(config-if)#ip add 192.168.4.1 255.255.255.0

Istvan KalmarHead of IT Security Division
Top Expert 2010

Commented:
HI,

AT the 2821
VLAN 2 - 192.168.2.0 255.255.255.0
VLAN 3 - 192.168.3.0 255.255.255.0
VLAN 4 - 192.168.4.0 255.255.255.0

Router(config)# interGice Gi0/1.2
Router(config-if)#encap dot1q 2 native
Router(config-if)#ip add 192.168.2.1 255.255.255.0
Router(config)# interGice Gi0/1.3
Router(config-if)#encap dot1q 3
Router(config-if)#ip add 192.168.3.1 255.255.255.0
Router(config)# interGice Gi0/1.4
Router(config-if)#encap dot1q 4
Router(config-if)#ip add 192.168.4.1 255.255.255.0

Author

Commented:
Was looking for switch examples.
Istvan KalmarHead of IT Security Division
Top Expert 2010

Commented:

Commented:
Use the set vlan <number> <port-number> to add the VLANs you want to the port. Exampl set vlan 2 2/1. Also, to setup a trunk it would be set trunk 2/1 on dot1q. This would turn on trunking and setup 802.1q trunking encapsulation.