vlan及静态路由配置vlan命令介绍一个交换机双交换机静态路由配置实验的概念实验
vlan命令介绍
以太网是100M接口
千兆以太网是1000M接口
以太网无法配置IP是因为此接口是双重端口,因此无法设置IP
access只能通过一个vlan,而trunk可以通过多个vlan。即在交换机和交换机之间连接的端口应该设置为trunk
单个开关
1 .首先为三台pc分配ip
配置vlan并操作端口
首先创建vlan10和vlan20
进入Switchen//特权模式Switch#conf t//全局配置Enter configuration commands,oneperline.end with cntl/z.switch (config ) #
switch#conftswitch(config ) intfa0/1switch (config-if ) switchportaccessVLAN10switch ) config ) intfa0/2 switch switchportaccessvlan 10 switch (config-if ) exit switch (config ) config (intfa0/3switch ) config-if ) switchportachportachportacestachporactessssssvlating
int Fa0/1交换机模式访问//先更改模式将访问交换机访问vlan 10接口更改为vlan 10
此时PC0http://www.Sina.com/PC2、ping通pc1
双交换机静态路由配置实验概念
实验1 .首先在两台主机上配置ip和网关(没有网关的话无法ping ) )。
PC0网关: 192.168.1.2
PC1网关: 192.168.3.1
在route0和1端口上分别配置ip
route0
路由器# conftenterconfigurationcommands, oneperline.end with cntl/z.router (config ) ) #int fa 0/0//进入端口router (config-if ) # IP address 192.168.1.2255 0路由器) config-if ) ) IP地址192.168.2.1255.255.255.0路由器) ) )。
router(config ) intse2/0router (config-if ) ) IP address 192.168.2.2255.255.255.0 router (config-if ) ) no shutdown保证各网段(一条线)属于同一网络号码
ping不通:缺省网关(Default Gateway )是一种子网连接到外部网的设备,通常为路由器。 当某计算机发送消息时,根据发送消息的目的地址,用子网掩码判定目的主机是否在本地子网中,如果目的主机在本地子网中,则直接发送即可。 如果目标不在本地子网中,则将此信息发送到默认网关/路由器,然后路由器将其转发到其他网络以搜索目标主机。
3 .配置静态路由表
在route0上设定下一个跳转(从左到右) )。
route1(config ) IP route 192.168.3.0255.255.255.0192.168.2 router ) config ) #end//目标网络号,数据
路由器(config ) IP路由192.168.1.0255.255.255.0192.168.2.1路由配置) #end 4.检查:路由表
查看route0路由表
在show ip route中,您可以看到route0直接连接了1和2网段。 在32跳。
5 .结果: PC0成功ping pc1
PC1也成功ping了PC0