单臂路由实现不同VLAN主机的通信
实验前知识点:
trunk口是什么?VLAN是什么?
trunk口可以汇聚多个VLAN,进行转发;VLAN虚拟局域网:https://baike.baidu.com/item/%E8%99%9A%E6%8B%9F%E5%B1%80%E5%9F%9F%E7%BD%91/419962?fromtitle=VLAN&fromid=320429&fr=aladdin
交换机的三种接口(access,trunk,hybrid)一般默认access:https://www.cnblogs.com/balabalala/p/7699799.html
实验拓扑图:
实验步骤:
配置相关主机的IP地址和对应的网关.
交换机划分VLAN,将相应的VLAN添加到对应的端口
将交换机与交换机连接的Fa0/4和Fa0/1端口设置成trunk口.这样相同VLAN之间的主机就可以通信(ping通)
要实现不同VLAN间的通信还需要配置路由
进入到路由的Fa0/0端口,配置相应的子接口,将对应网关绑定到对应的VLAN,配置相应VLAN主机对应的网关(如192.168.10.254;192.168.20.254):
Router(config)#int f0/0
Router(config-if)#no shutdown 开启物理端口
Router(config-if)#exit
Router(config)#int f0/0.10 进入子接口
Router(config-subif)#encapsulation dot1Q 10 封装相应的VLAN
Router(config-subif)#ip address 192.168.1.254 255.255.255.0 配置默认网关
Router(config)#int f0/0.20
Router(config-subif)#encapsulation dot1Q 20
Router(config-subif)#ip address 192.168.2.254 255.255.255.0
Router(config)#do show ip int b 查看端口的信息
将路由器交换机的端口Fa0/3设置为trunk口
不同VLAN的主机就可以通信啦