三层交换机组建vlan入门手册.docx
《三层交换机组建vlan入门手册.docx》由会员分享,可在线阅读,更多相关《三层交换机组建vlan入门手册.docx(13页珍藏版)》请在冰点文库上搜索。
三层交换机组建vlan入门手册
三层交换机组建vlan入门
1.交换机的ip如何配置
一般vlan1的ip就是交换机的管理ip,交换机的ip配置,可以理解为vlan1配置ip,当然选择其它vlan也可以。
2.vlan在哪里划分
三层交换机上先创建域,然后划分vlanx,并为vlanx分配ip(这个ip就是vlanx内所有pc的网关),二层交换机只要加入到域,并将端口分配到相应的vlan就可以了
3.如何telnet远端管理交换机
在三层交换机上配置vlan1的ip并启动vlan1,设置特权密码,开启虚拟终端vty,设置访问密码,然后在二层交换机上配置vlan1的ip并启动vlan1,设置特权密码,开启虚拟终端vty,设置访问密码,并在二层交换机上配置默认网关为三层交换机vlan1的ip.
网络拓扑图如下
三层交换机:
3560Switch1f0/24----------------二成交换机:
2950TSwitch2:
f0/24
三层交换机:
3560Switch1f0/23----------------二成交换机:
2950TSwitch3:
f0/24
二成交换机:
2950TSwitch3:
f0/1-----------------pc192.168.10.12
二成交换机:
2950TSwitch3:
f0/2-----------------pc192.168.20.12
二成交换机:
2950TSwitch2:
f0/1-----------------pc192.168.10.11
二成交换机:
2950TSwitch2:
f0/2-----------------pc192.168.20.11
分两部分来讲解{如何在三层交换机上实现vlan的划分和不同vlan间的相互访问
{如何实现不同vlan的PC可以telnet来远程管理交换机
如何在三层交换机上实现vlan的划分和不同vlan间的相互访问
全局配置思路
1.在三层交换机上配置域(server)
2.在三层交换机上创建vlan
3.在三层交换机上为每个vlan配置ip
4.在三层交换机上配置trunk口
5.在二层交换机上配置域(client)
6.在二层交换机上配置trunk口
7.在二层交换机上将端口分配到vlan
以下为实际配置全过程,黑色部分为系统文字,蓝色部分为我输入命令或提示
Switch>enable进入特权模式
Switch#config进入全局模式
Configuringfromterminal,memory,ornetwork[terminal]?
Terminal进入配置模式
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Switch(config)#vtpdomainichia创建域,名为ichia
ChangingVTPdomainnamefromNULLtoichia
Switch(config)#vtpmodeserver设置为域服务器
DevicemodealreadyVTPSERVER.
Switch(config)#exit退出全局模式
Switch#vlandatabase进入vlan模式
%Warning:
ItisrecommendedtoconfigureVLANfromconfigmode,
asVLANdatabasemodeisbeingdeprecated.Pleaseconsultuser
documentationforconfiguringVTP/VLANinconfigmode.
Switch(vlan)#vlan10创建vlan10
VLAN10added:
Name:
VLAN0010系统默认为这个vlan分配了一个名字
Switch(vlan)#vlan20创建vlan20
VLAN20added:
Name:
VLAN0020
Switch(vlan)#exit
APPLYcompleted.
Exiting....
Switch#config进入全局模式
Configuringfromterminal,memory,ornetwork[terminal]?
Terminal进入配置模式
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Switch(config)#intvlan10进入vlan10
%LINK-5-CHANGED:
InterfaceVlan10,changedstatetoup
Switch(config-if)#ipadd192.168.10.1255.255.255.0为vlan10分配ip地址,这个地址也是这个vlan的网关
Switch(config-if)#exit
Switch(config)#intvlan20
%LINK-5-CHANGED:
InterfaceVlan20,changedstatetoup
Switch(config-if)#ipadd192.168.20.1255.255.255.0
Switch(config-if)#exit
Switch(config)#intf0/24三层交换机上的24,23端口被用来做trunk口
Switch(config-if)#switchportmodetrunk
Commandrejected:
Aninterfacewhosetrunkencapsulationis"Auto"cannotbeconfiguredto"trunk"mode.
这个地方提示错误,因为需要先配置协议:
dot1q为802.1Q协议,ISL为思科专用vlan协议
Switch(config-if)#switchporttrunkencapsulationdot1q
Switch(config-if)#switchportmodetrunk
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceFastEthernet0/24,changedstatetodown
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceFastEthernet0/24,changedstatetoup
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceVlan10,changedstatetoup
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceVlan20,changedstatetoup
Switch(config-if)#exit
Switch(config)#intf0/23
Switch(config-if)#switchporttrunkencapsulationdot1q设置802.1Q网络协议
Switch(config-if)#switchportmodetrunk设置为trunk口
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceFastEthernet0/23,changedstatetodown
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceFastEthernet0/23,changedstatetoup
Switch(config-if)#exit
Switch(config)#exit
%SYS-5-CONFIG_I:
Configuredfromconsolebyconsole
Switch#exit
Switchcon0isnowavailable
三层交换机部分就算设置好了
下面进入到二层交换机部分
Switch>enable
Switch#config
Configuringfromterminal,memory,ornetwork[terminal]?
terminal
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Switch(config)#vtpdomainichia加入到ichia域
Domainnamealreadysettoichia.
Switch(config)#vtpmodeclient在域中扮演用户端的角色
SettingdevicetoVTPCLIENTmode.
Switch(config)#intf0/24进入端口24
Switch(config-if)#switchportmodetrunk设置端口为trunk口
Switch(config-if)#exit
Switch(config)#intf0/1进入端口1
Switch(config-if)#switchportaccessvlan10将端口分配给vlan10
Switch(config-if)#exit
Switch(config)#intf0/2进入端口2
Switch(config-if)#switchportaccessvlan20将端口分配给vlan20
Switch(config-if)#exit
Switch(config)#exit
以上为二层交换机的配置内容
交换机Switch3的配置和Switch2基本一样
配置完成后我们直接在pc上测试
从图上可以看到:
192.168.20.11ping192.168.10.11成功
192.168.20.11ping192.168.20.12成功
如何实现不同vlan的PC可以telnet来远程管理交换机
配置思路
1.三层交换机配置vlan1的ip,开启vlan1,配置特权密码,开启VTY和访问密码
2.二层交换机配置vlan1的ip,开启vlan1,设置网关为三层交换机vlan1的ip地址,配置特权密码,开启vty和访问密码。
先配置三层交换机
Switch>enable进入特权模式
Switch#vlandatabase进入vlan设置
%Warning:
ItisrecommendedtoconfigureVLANfromconfigmode,
asVLANdatabasemodeisbeingdeprecated.Pleaseconsultuser
documentationforconfiguringVTP/VLANinconfigmode.
Switch(vlan)#vlan1创建vlan1
VLAN1modified:
Switch(vlan)#exit
APPLYcompleted.
Exiting....
Switch#configt进入全局模式
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Switch(config)#intvlan1进入vlan1
Switch(config-if)#ipadd192.168.128.1255.255.255.0配置vlan1的ip地址,子网掩码
Switch(config-if)#noshutdown开启vlan1
%LINK-5-CHANGED:
InterfaceVlan1,changedstatetoup
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceVlan1,changedstatetoup
Switch(config-if)#exit
Switch(config)#lineconsole0进入控制台口
Switch(config-line)#linevty04进入虚拟终端,这里04表示开启01234五个连接
Switch(config-line)#login允许登录
Switch(config-line)#password123456登录密码123456
Switch(config-line)#exit
Switch(config)#exit
%SYS-5-CONFIG_I:
Configuredfromconsolebyconsole
Switch#
Switch#showvlan
二层交换机的配置(switch2)
Switch>en
Switch#vlandatabase进入vlan设置
%Warning:
ItisrecommendedtoconfigureVLANfromconfigmode,
asVLANdatabasemodeisbeingdeprecated.Pleaseconsultuser
documentationforconfiguringVTP/VLANinconfigmode.这里可以看到其实系统已经开始警告了
Switch(vlan)#vlan1
VTPVLANconfigurationnotallowedwhendeviceisinCLIENTmode.对于上面的警告,这里给出了解释
Switch(vlan)#exit在域里面只有server可以创建,修改vlan
APPLYcompleted.而二层交换机充当的角色是client
Exiting....
Switch#configt进入特权模式
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Switch(config)#enablepassword123456设置特权模式密码:
123456/*这里下面会有一个小测试*/
Switch(config)#intvlan1进入vlan1
Switch(config-if)#ipadd192.168.128.2255.255.255.0配置ip,子网掩码
Switch(config-if)#exit
Switch(config)#ipdefault-gateway192.168.128.1在全局模式下配置网关,为三层交换机的ip地址
Switch(config)#intvlan1
Switch(config-if)#noshutdown开启vlan1
%LINK-5-CHANGED:
InterfaceVlan1,changedstatetoup
%LINEPROTO-5-UPDOWN:
LineprotocolonInterfaceVlan1,changedstatetoup
Switch(config-if)#exit
Switch(config)#exit
%SYS-5-CONFIG_I:
Configuredfromconsolebyconsole
Switch#configt
Enterconfigurationcommands,oneperline.EndwithCNTL/Z.
Switch(config)#lineconsole0进入控制端口
Switch(config-line)#linevty04开通01234五个端口
Switch(config-line)#login允许登录
%Logindisabledonline1,until'password'isset
%Logindisabledonline2,until'password'isset
%Logindisabledonline3,until'password'isset
%Logindisabledonline4,until'password'isset
%Logindisabledonline5,until'password'isset
Switch(config-line)#password123456
Switch(config-line)#exit
Switch(config)#exit
%SYS-5-CONFIG_I:
Configuredfromconsolebyconsole
做到这里,switch2已经配置完成了,在这里我们可以做几个小测试,看看其中的区别
1.用pc192.168.20.11来ping192.168.128.1和192.168.128.2
2.用telnet来登录到switch1和switch2
这里看到switch1可以连接上,但是没办法进入,而switch2可以正常连接,正常进入,因为switch1没有配置特权密码
Switch3的配置和switch2的配置是一样的。
除了ip192.168.128.3
其实电脑要连上switch1是最容易的,因为它充当路由功能,所有的网关都会指向它,下面我们测试了这个结果,用PC连自己的网关也是可以连上switch1的。