Let’s say we have to set up a small office network. We have a router and switch, and some end user workstations that we want to keep in separate VLANs.

image

Accounting Dept. PC is configured with the following settings:

IP address: 10.10.1.254
Subnet mask: 255.255.255.0
Default Gateway: 10.10.1.1

Engineering Dept. PC is configured with the following settings:

IP address: 10.20.1.254
Subnet mask: 255.255.255.0
Default Gateway: 10.20.1.1

Let’s configure the switch fist.

S1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#int fa0/2
S1(config-if)#description :: Accounting Dept PC ::
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 10
% Access VLAN does not exist. Creating vlan 10
S1(config-if)#

S1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#int f0/1
S1(config-if)#description :: Engineering Dept PC ::
S1(config-if)#switchport mode access
S1(config-if)#switchport access vlan 20
% Access VLAN does not exist. Creating vlan 20

We can verify that VLANs 10 and 20 were created properly and that interfaces FastEthernet 0/1 and 0/2 have been configured properly by issuing the show vlan brief command.

S1#sh vlan bri

VLAN Name                             Status    Ports
—- ——————————– ——— ——————————-
1    default                          active    Fa0/3, Fa0/4, Fa0/5, Fa0/6
                                                Fa0/7, Fa0/8, Fa0/9, Fa0/10
                                                Fa0/11, Fa0/12, Fa0/13, Fa0/14
                                                Fa0/15, Fa0/16, Fa0/17, Fa0/18
                                                Fa0/19, Fa0/20, Fa0/21, Fa0/22
                                                Fa0/23, Fa0/24, Gig0/1, Gig0/2
10   VLAN0010                         active    Fa0/2
20   VLAN0020                         active    Fa0/1

1002 fddi-default                     active   
1003 token-ring-default               active   
1004 fddinet-default                  active   
1005 trnet-default                    active
   

Next, we’ll need to create the two SVIs.

S1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
S1(config)#interface vlan10
S1(config-if)#
%LINK-5-CHANGED: Interface Vlan10, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan10, changed state to up

S1(config-if)#description AccountingVLAN
S1(config-if)#ip address 10.10.1.253 255.255.255.0

S1(config)#interface vlan 20
%LINK-5-CHANGED: Interface Vlan20, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan20, changed state to up

S1(config-if)#description EngineeringVLAN
S1(config-if)#ip address 10.20.1.253 255.255.255.0

Now, let’s configure the trunk between interface FastEthernet 0/3 on Switch1 and Interface FastEthernet 0/0 on Router1.

On Switch1 we’ll configure the switchport to act as trunk, using 802.1q encapsulation. In addition, we’ll allow VLAN 10 and 20 traffic to cross the trunk.

S1(config)#interface Fa0/3
S1(config-if)#description :: Trunk to R1 Fa0/0 ::
S1(config-if)#switchport trunk encapsulation dot1q
S1(config-if)#switchport mode trunk
S1(config-if)#switchport trunk allowed vlan 10,20

On Router1 first we’ll shutdown interface FastEthernet 0/0

R1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
R1(config)#interface fastethernet0/0
R1(config-if)#no ip address
R1(config-if)#no shut

R1(config-if)#
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up

R1(config-if)#

Then we’ll create two subinterfaces which will act as gateways for the two VLANs.

R1(config)#interface fastethernet 0/0.10
R1(config-subif)#
%LINK-5-CHANGED: Interface FastEthernet0/0.10, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.10, changed state to up

R1(config-subif)#encapsulation dot1q 10
R1(config-subif)#ip address 10.10.1.1 255.255.255.0
R1(config-subif)#no shut

R1(config)#interface fastethernet 0/0.20
R1(config-subif)#
%LINK-5-CHANGED: Interface FastEthernet0/0.20, changed state to up

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.20, changed state to up
encapsulation dot1q 20
R1(config-subif)#ip address 10.20.1.1 255.255.255.0
R1(config-subif)#no shut

Lastly let’s verify that PCs can ping each other.

imageimage

And that R1 can get to both end user workstations.

image

%d bloggers like this: