Router(config-subif)#encapsulation dot1q 10 //指定封装格式是802.1q关联VLAN 10
Router(config-subif)#interface fa0/0.20
Router(config-subif)#encapsulation dot1q 20
Router(config-subif)#interface fa0/0.30
Router(config-subif)#encapsulation dot1q 30
Router(config-subif)#ip address 192.168.30.1 255.255.255.0
Router(config-subif)#exit
Router(config)#interface fa0/0
Router(config-if)#no shutdown //配置结束,启动接口,同时子接口也一起启动
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
%LINK-5-CHANGED: Interface FastEthernet0/0.10, changed state to up
Router(config-if)#
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.10, changed state to up
%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
%LINK-5-CHANGED: Interface FastEthernet0/0.30, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.30, changed state to up
Switch(config-vlan)#name guanli //为VLAN命名
Switch(config-vlan)#exit
Switch(config)#vlan 20
Switch(config-vlan)#name jishu
Switch(config-vlan)#exit
Switch(config)#
Switch(config)#vlan 30
Switch(config-vlan)#exit
Switch(config)#
Switch(config)#interface range fa0/1-10 //进入接口
Switch(config-if-range)#switchport mode access //将接口模式设为access模式
Switch(config-if-range)#switchport access vlan 10 //将接口加入VLAN
Switch(config-if-range)#interface range fa0/11-20
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 20
Switch(config-if-range)#interface range fa0/21-24
Switch(config-if-range)#switchport mode access
Switch(config-if-range)#switchport access vlan 30
Switch(config-if-range)#exit