Router-On-A-Stick
Now consider yourself again as a network engineer in a bank. This time the scenario is that your treasury department, finance department and human resource are on the same switch. Now we know that the switch broadcast packets to all the ports, so if someone from the treasury department sends a packet to the finance department, it will be broadcasted to the human resource department also. Even if you put both the departments in a different Vlan together, still the packets will not be forwarded to the destination rather than broadcasted to all interfaces which we don't want. The forwarding of packets from source to destination is the job for a router. The process of forwarding packets between VLAN's is called InterVLAN routing. For forwarding packets, you need to connect the switch with the router. This feature is also known as Router-On-A-Stick.Now take three pc's and a router and connect it with a switch. Connect the router with interface 0/1 and connect the pc's with interface 0/3 and 0/5 as shown below.
Now go to the switch and create vlan 3 and vlan 5.
switch(config)# vlan 3
switch(config-vlan)# name vlan03
switch(config)# vlan 5
switch(config-vlan)# name vlan05
switch(config-vlan)# exit
Now assign vlan 3 to interface fa 0/3 and vlan 5 to interface fa 0/5 and made fa 0/1 trunk port between the switch and router.
switch(config)# interface fa 0/3
switch(config-if)# switchport mode access
switch(config-if)# switchport access vlan 3
switch(config-if)# exit
switch(config)# interface fa 0/5
switch(config-if)# switchport mode access
switch(config-if)# switchport access vlan 5
switch(config-if)# exit
switch(config)# interface fa 0/1
switch(config-if)# switchport mode trunk
switch(config-if)# exit
Now you need to assign ip's to vlan 3 and vlan 5.
switch(config)# interface vlan 3
switch(config-if)# ip address 192.168.3.2 255.255.255.0
switch(config-if)# no shutdown
switch(config)# exit
switch(config)# interface vlan 5
switch(config-if)# ip address 192.168.5.2 255.255.255.0
switch(config-if)# no shutdown
switch(config)# exit
Now the work of the switch has been completed. Lets move on to the router. Now here we need to create subinterfaces for trunking to forward packet between VLAN's and we will use dot1q trunking. The command will be "encapsulation dot1q vlanid ".
router(config)# interface fa 0/0.1
router(config-subif)# encapsulation dot1q 3
router(config-subif)# ip address 192.168.3.1 255.255.255.0
router(config)# interface fa 0/0.2
router(config-subif)# encapsulation dot1q5
router(config-subif)# ip address 192.168.5.1 255.255.255.0
router(config)# interface fa 0/0
router(config-if)# no shutdown
The "no shutdown " command on interface fa 0/0 helps to active the port. Now assign IP's and gateways to both PC's as shown below :
No comments:
Post a Comment