To make 2 separate network usually we use 2 sepearate switches and configure router according to that. But its also possible to maintain multiple networks using a single switch. That can be done in two ways:-
Traditional way: Suppose we have two networks (VLAN) connected with the switch. Therefore two connections are also made from switch to a router and each port of the router is configured with an IP Address of a particular VLAN. For larger networks its quite impossible to maintain a single port of the router for each VLAN. So a modern way is followed to overcome this problem.
Modern way: In this case, a trunk path is created in between the switch and the router. Then sub-interface is defined to the router port that the switch is connected to. Code to accomplish this task is given below:-
Assuming the trunk path is connected to fast ethernet 0/5 of the router.
#config:interface fa0/5.10;
#config(sub-if):encapsulation dotIq 10
#config(sub-if):ip address 172.16.10.1;
Similarly other networks are configured. To configure native vlan we need to write encapsulation dotIq 99 native.
No shut command is inserted under the actual interface mode like below:-
#config:interface fast-Ethernet 0/5;
#config(if):no shut;