子网划分器代码 通过子网掩码划分子网( 二 )


switch(config)#
接口配置模式:switch(config)#int f0/1
switch(config-if)#
Line模式:switch(config)# line console 0
switch(config-line)#
2)配置实例:PC0、PC1、PC2分别挂接在交换机的端口1、端口2与端口3上 。配置的IP地址分别为:172.31.0.1/172.31.0.2/172.31.0.3,实例中需要将端口1加入到VLAN 10;将端口2加入到VLAN 20;将端口3加入到VLAN 30 。

子网划分器代码 通过子网掩码划分子网

文章插图
文章插图
基于端口的子网划分
Switch>en 从用户模式转到特权模式
Switch#sh vlan 查看vlan
VLAN Name Status Ports
—- ——————————– ——— ——————————-
1 default active Fa0/1, Fa0/2, 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
1002 fddi-default active
【子网划分器代码 通过子网掩码划分子网】1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
—- —– ———- —– —— —— ——– —- ——– —— ——
1 enet 100001 1500 – – – – – 0 0
1002 fddi 101002 1500 – – – – – 0 0
1003 tr 101003 1500 – – – – – 0 0
1004 fdnet 101004 1500 – – – ieee – 0 0
1005 trnet 101005 1500 – – – ibm – 0 0
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
—- —– ———- —– —— —— ——– —- ——– —— ——
Remote SPAN VLANs
——————————————————————————
Primary Secondary Type Ports
——- ——— —————– ——————————————
Switch#conf t 从特权模式转到全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 10 创建VLAN 10
Switch(config-vlan)#name vlan10 给新建的VLAN命名
Switch(config-vlan)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#conf t 进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/1 进入端口1
Switch(config-if)#sw mo ac 初始化端口
Switch(config-if)#sw ac vlan 10 将端口1加入VLAN 10
Switch(config-if)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#conf t 进入全局配置模式
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 20 创建VLAN 20
Switch(config-vlan)#name vlan20
Switch(config-vlan)#end
%SYS-5-CONFIG_I: Configured from console by console
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/2 进入端口2
Switch(config-if)#sw mo ac 初始化端口
Switch(config-if)#sw ac vlan 20 将端口2加入VLAN 20
Switch(config-if)#end
%SYS-5-CONFIG_I: Configured from console by console
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#vlan 30 创建VLAN 30
Switch(config-vlan)#name vlan30
Switch(config-vlan)#end
%SYS-5-CONFIG_I: Configured from console by console
Switch#conf t
Enter configuration commands, one per line. End with CNTL/Z.
Switch(config)#int f0/3 进入端口3
Switch(config-if)#sw mo ac 初始化端口
Switch(config-if)#sw ac vlan 30 将端口3加入VLAN 30
Switch(config-if)#end
Switch#
%SYS-5-CONFIG_I: Configured from console by console
Switch#sh vlan
VLAN Name Status Ports
—- ——————————– ——— ——————————-
1 default active 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 vlan10 active Fa0/1
20 vlan20 active Fa0/2
30 vlan30 active Fa0/3
1002 fddi-default active
1003 token-ring-default active
1004 fddinet-default active
1005 trnet-default active
VLAN Type SAID MTU Parent RingNo BridgeNo Stp BrdgMode Trans1 Trans2
结语:好了 。

推荐阅读