8.4.3 使用3:配置单臂路由实现VLAN间路由

1、实验目的

通过本实验可以掌握:

  1. 路由器以太网接口上的子接口配置和调试方法。
  2. 单臂路由实现 VLAN间路由的配置和调试方法。

2、实验拓扑

实验拓扑如下图所示。

3、实验步骤

(1)配置交换机S1

复制代码
S1(config)#vlan 2
S1(config-vlan)#exit
S1(config)#vlan 3
S1(config-vlan)#exit
S1(config)#interface fastEthernet 0/1
S1(config-if)#switchport mode access 
S1(config-if)#switchport access vlan 2
S1(config-if)#exit
S1(config)#interface fastEthernet 0/2
S1(config-if)#switchport mode access 
S1(config-if)#switchport access vlan 3
S1(config-if)#exit
S1(config)#interface gigabitEthernet 0/1
S1(config-if)#switchport mode trunk        //与路由器相连的接口被配置成Trunk接口
S1(config-if)#exit

(2)配置路由R1

复制代码
R1(config)#interface gigabitEthernet 0/0
R1(config-if)#no shutdown 
R1(config-if)#exit
R1(config)#interface gigabitEthernet 0/0.2   //创建子接口,子接口的编号一般建议和VLAN号码对应
R1(config-subif)#encapsulation dot1Q 2       //定义子接口承载哪个VLAN流量
R1(config-subif)#ip address 172.16.2.254 255.255.255.0  //在子接口上配置IP地址,这个地址就是 VLAN2主机的默认网关
R1(config-subif)#exit
R1(config)#interface gigabitEthernet 0/0.3
R1(config-subif)#encapsulation dot1Q 3
R1(config-subif)#ip address 172.16.3.254 255.255.255.0   
R1(config-subif)#exit

4、实验调试

(1)查看路由表

复制代码
R1#show ip route connected 
 C   172.16.2.0/24  is directly connected, GigabitEthernet0/0.2
 C   172.16.3.0/24  is directly connected, GigabitEthernet0/0.3

以上输出表明,R1的路由表中存在两条直连路由,其出接口为相应子接口。

(2)从PC1 上 ping PC2

PC1 ping PC2可以通信,表明VLAN2和VLAN3两个VLAN间的主机已经可以通过单臂路由进行通信了。

相关推荐
kfepiza3 小时前
Debian的`/etc/network/interfaces`的`allow-hotplug`和`auto`对比讲解 笔记250704
linux·服务器·网络·笔记·debian
无妄-20243 小时前
软件架构升级中的“隐形地雷”:版本选型与依赖链风险
java·服务器·网络·经验分享
群联云防护小杜5 小时前
构建分布式高防架构实现业务零中断
前端·网络·分布式·tcp/ip·安全·游戏·架构
岸边的风7 小时前
无需公网IP的文件交互:FileCodeBox容器化部署技术解析
网络·网络协议·tcp/ip
Zonda要好好学习8 小时前
Python入门Day4
java·网络·python
riverz12278 小时前
TCP backlog工作机制
服务器·网络·tcp/ip
yqcoder9 小时前
1. http 有哪些版本,你是用的哪个版本,怎么查看
网络·网络协议·http
Fanmeang12 小时前
OSPF路由过滤
运维·网络·华为·ip·路由·ospf·路由过滤
我是阿呆同学13 小时前
仿mudou库one thread oneloop式并发服务器
网络
是阿建吖!13 小时前
【Linux | 网络】网络编程套接字
linux·网络