对交换机的配置:
Switch>
Switch>
Switch>
Switch>en
Switch>
Switch>en
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
Switch#vlan d
Switch#vlan database
% Warning: It is recommended to configure VLAN from config mode,
as VLAN database mode is being deprecated. Please consult user
documentation for configuring VTP/VLAN in config mode.
Switch(vlan)#vlan 2 name a
VLAN 2 added:
Name: a
Switch(vlan)#vlan 3 name b
VLAN 3 added:
Name: b
Switch(vlan)#exit
APPLY completed.
Exiting....
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int vlan 2
%LINK-5-CHANGED: Interface Vlan2, changed state to upSwitch(config-if)#
Switch(config-if)#no shu
Switch(config-if)#int vlan 3
%LINK-5-CHANGED: Interface Vlan3, changed state to upSwitch(config-if)#
Switch(config-if)#no shu
Switch(config-if)#int f0/1
Switch(config-if)#sw m ac
Switch(config-if)#sw ac vlan 2
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan2, changed state to upSwitch(config-if)#
Switch(config-if)#int f0/2
Switch(config-if)#sw m ac
Switch(config-if)#sw ac vlan 3
%LINEPROTO-5-UPDOWN: Line protocol on Interface Vlan3, changed state to upSwitch(config-if)#
Switch(config-if)#int f0/3
Switch(config-if)#sw m ac
Switch(config-if)#sw ac vlan 2
Switch(config-if)#int f0/4
Switch(config-if)#sw m ac
Switch(config-if)#sw ac vlan 3
Switch(config-if)#int f0/5
Switch(config-if)#no shu
Switch(config-if)#sw m ac
Switch(config-if)#sw m tr
Switch(config-if)#exit
Switch(config)#exit
%SYS-5-CONFIG_I: Configured from console by console
Switch#
对路由器的配置:
Press RETURN to get started!
Router>
Router>
Router>en
Router#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Router(config)#int f0/0
Router(config-if)#no shu
%LINK-5-CHANGED: Interface FastEthernet0/0, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0, changed state to up
Router(config-if)#no ip ad
Router(config-if)#no ip address
Router(config-if)#int f0/0.1
%LINK-5-CHANGED: Interface FastEthernet0/0.1, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.1, changed state to upRouter(config-subif)#
Router(config-subif)#en
Router(config-subif)#encapsulation d
Router(config-subif)#encapsulation dot1Q 2
Router(config-subif)#ip ad
Router(config-subif)#ip address 192.168.1.1 255.255.255.0
Router(config-subif)#int f0/0.2
%LINK-5-CHANGED: Interface FastEthernet0/0.2, changed state to up
%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/0.2, changed state to upRouter(config-subif)#
Router(config-subif)#en
Router(config-subif)#encapsulation d
Router(config-subif)#encapsulation dot1Q 3
Router(config-subif)#ip ad
Router(config-subif)#ip address 192.168.2.1 255.255.255.0
Router(config-subif)#exit
Router(config)#
我是在模拟器上做的,你可以看看这些命令,要是不明白的话再问吧。
封装
添加IP地址这个IP地址就是VLAN 网关
交换机连接路由的口起TRUNK
PC指默认网关就可以了。
SW1:
#模式下:入vlan database用vlan [vlan ID]新建vlan.例如vlan2(本来已经有个vlan1
在conf t模式下:
int vlan 1
ip add 192.168.1.1 255.255.255.0(vlan1网关.vlan1电脑网段网关按照这个设置)
int vlan 2
ip add 192.168.2.1 255.255.255.0(vlan2网关.vlan2电脑网段网关按照这个设置)
ip routing(启用路由功能)
int fa0/1进入端口1
sw mo acc设置模式访问状态
sw acc vlan 1吧int fa 0/1放入vlan1.2层一样这样设置.不详细说.
------淫-荡-的-分-割-线------
2层交换机情况下:
端口放入不用说.以上说了.
假设int fa 1/5连接路由器.则:
int fa 1/5
sw mo tr吧端口配置成trunk模式
sw tr enc d并封装IEEE 802.1q协议
R1:
int fa 0/0
iP add 192.168.1.1 255.255.255.0(VLAN1网关)
int fa 0/0.1(子接口)
ip add 192.168.2.1 255.255.255.0(VLAN2网关)
enc d(封装IEEE 802.1q协议)
电脑IP编址..不用我说了吧..