思科配置:vlan、两个交换机、两个路由器、四台主机

一、如图配置

各设备ip地址、接口、vlan如图所示。 

二、配置各主机ip、子网掩码、默认网关

PC0

PC8

PC1 

PC9

PC2 

PC10 

PC3 

PC11 

三、配置Switch0

(期间报错为拼写错误) 

MySwitch0>
MySwitch0>en
MySwitch0#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
MySwitch0(config)#vlan 1
MySwitch0(config-vlan)#ex
MySwitch0(config)#interface f0/1
MySwitch0(config-if)#switchport mode access
MySwitch0(config-if)#switchport access vlan 1
MySwitch0(config-if)#ex
MySwitch0(config)#interface f0/3
MySwitch0(config-if)#switchport mode access
MySwitch0(config-if)#switchport access vlan 1
MySwitch0(config-if)#ex
MySwitch0(config)#int f0/2
MySwitch0(config-if)#ex
MySwitch0(config)#vlan 2
MySwitch0(config-vlan)#ex
MySwitch0(config)#interface f0/2
MySwitch0(config-if)#switchport mode access
MySwitch0(config-if)#switchport access vlan 1
MySwitch0(config-if)#ex
MySwitch0(config)#int f0/2
MySwitch0(config-if)#no switchport access vlan 1
MySwitch0(config-if)#ex
MySwitch0(config)#int f0/2
MySwitch0(config-if)#switchport mode access
MySwitch0(config-if)#switchport access vlan 2
MySwitch0(config-if)#ex
MySwitch0(config)#int f0/4
MySwitch0(config-if)#switchport mode access
MySwitch0(config-if)#switchport access vlan 2
MySwitch0(config-if)#ex
MySwitch0(config)#ex
MySwitch0#
%SYS-5-CONFIG_I: Configured from console by console

MySwitch0#

四、配置Switch1

交换机1配置参考交换机0,只是vlan略有不同,如图配置即可。

五、路由器配置

路由器配置参考文章:思科配置路由器,四台主机互相ping通-CSDN博客

六、命令总结

MySwitch0>en
MySwitch0#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
MySwitch0(config)#vlan 1
MySwitch0(config-vlan)#ex
MySwitch0(config)#interface f0/1
MySwitch0(config-if)#switchport mode access
MySwitch0(config-if)#switchport access vlan 1

七、取消配置的vlan

MySwitch1(config-if)#interface fa0/5
MySwitch1(config-if)#no switchport access vlan 22

八、ping截图

 

九、注意事项

需要注意的是交换机到路由器的vlan是1,所以说PC10为vlan11的主机是ping不通默认网关172.2.2.3的。 

十、Trunk模式

要允许交换机上的任何VLAN都可以通过到路由器,您需要配置交换机的一个或多个端口为Trunk模式。Trunk端口允许多个VLAN的流量通过同一个物理接口,这通常用于连接交换机和路由器,或连接交换机和交换机。 

MySwitch(config)#interface fa0/1
MySwitch(config-if)#switchport mode trunk
MySwitch(config-if)#switchport trunk allowed vlan all

 先设置Switch1的fa0/5为Trunk模式:

MySwitch1#en
MySwitch1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
MySwitch1(config)#int f0/5
MySwitch1(config-if)#switchport mode trunk

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/5, changed state to up

MySwitch1(config-if)#switchport trunk allowed vlan all
MySwitch1(config-if)#ex
MySwitch1(config)#

再设置Switch1的fa0/3为Trunk模式:

MySwitch1>en
MySwitch1#conf t
Enter configuration commands, one per line.  End with CNTL/Z.
MySwitch1(config)#int f0/3
MySwitch1(config-if)#switchport mode trunk

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to down

%LINEPROTO-5-UPDOWN: Line protocol on Interface FastEthernet0/3, changed state to up

MySwitch1(config-if)#switchport trunk allowed vlan all
MySwitch1(config-if)#

PC10ping通默认网关172.2.2.3

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

脑子不好真君

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值