计算机网络—VLAN 间路由配置

目录

1.拓扑图

2.实验环境准备

[3.为 R3 配置 IP 地址](#3.为 R3 配置 IP 地址)

[4.创建 VLAN](#4.创建 VLAN)

[5.配置 R2 上的子接口实现 VLAN 间路由](#5.配置 R2 上的子接口实现 VLAN 间路由)

6.配置文件


1.拓扑图

2.实验环境准备

配置R1、R3和S1的设备名称,并按照拓扑图配置R1的G0/0/1接口的IP地址。

[Huawei]sysname R1
[R1]interface GigabitEthernet 0/0/1
[R1-GigabitEthernet0/0/1]ip address 10.0.4.1 24
<Huawei>system-view
Enter system view, return user view with Ctrl+Z. 
[Huawei]sysname R3
<Quidway>system-view
[Quidway]sysname S1

3.为 R3 配置 IP 地址

[R3]interface GigabitEthernet 0/0/1
[R3-GigabitEthernet0/0/1]ip address 10.0.8.1 24

4.创建 VLAN

在S1上创建VLAN 4和VLAN 8,将端口G0/0/1加入到VLAN 4中,将端口 G0/0/3加入到VLAN 8中。

[S1]vlan batch 4 8
Info: This operation may take a few seconds. Please wait for a moment...done.
[S1]interface GigabitEthernet 0/0/1
[S1-GigabitEthernet0/0/1]port link-type access
[S1-GigabitEthernet0/0/1]port default vlan 4
[S1-GigabitEthernet0/0/1]quit
[S1]interface GigabitEthernet0/0/3
[S1-GigabitEthernet0/0/3]port link-type access
[S1-GigabitEthernet0/0/3]port default vlan 8
[S1-GigabitEthernet0/0/3]quit

将S1连接R2路由器的G0/0/2端口配置为Trunk接口,并允许VLAN 4和 VLAN 8的报文通过。

[S1]interface GigabitEthernet0/0/2
[S1-GigabitEthernet0/0/2]port link-type trunk
[S1-GigabitEthernet0/0/2]port trunk allow-pass vlan 4 8

5.配置 R2 上的子接口实现 VLAN 间路由

由于路由器只有一个实际的物理接口与交换机S1相连,而实际上不同部门 属于不同VLAN和不同网段,所以在路由器上配置不同的逻辑子接口来扮演不同 的网关角色,在R2上配置子接口G0/0/1.1和G0/0/1.3,并作为VLAN 4和VLAN 8的网关。

<Huawei>system-view
Enter system view, return user view with Ctrl+Z. 
[Huawei]sysname R2
[R2]interface GigabitEthernet0/0/1.1
[R2-GigabitEthernet0/0/1.1]ip address 10.0.4.254 24
[R2-GigabitEthernet0/0/1.1]dot1q termination vid 4
[R2-GigabitEthernet0/0/1.1]arp broadcast enable
[R2-GigabitEthernet0/0/1.1]quit
[R2]interface GigabitEthernet0/0/1.3
[R2-GigabitEthernet0/0/1.3]ip address 10.0.8.254 24
[R2-GigabitEthernet0/0/1.3]dot1q termination vid 8
[R2-GigabitEthernet0/0/1.3]arp broadcast enable

在R1和R3上各配置一条默认路由指向各自的网关。

[R1]ip route-static 0.0.0.0 0.0.0.0 10.0.4.254

[R3]ip route-static 0.0.0.0 0.0.0.0 10.0.8.254

配置完成后,检测R1与R3间的连通性。

<R1>ping 10.0.8.1

[R2]display ip routing-table

10.0.4.0/24 Direct 0 0 D 10.0.4.254 GigabitEthernet0/0/1.1
10.0.8.0/24 Direct 0 0 D 10.0.8.254 GigabitEthernet0/0/1.3

6.配置文件

[R1]display current-configuration
[V200R007C00SPC600]
#
sysname R1
#
interface GigabitEthernet0/0/1
ip address 10.0.4.1 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 10.0.4.254
#
return
[R2]display current-configuration
[V200R007C00SPC600]
#
sysname R2
#
interface GigabitEthernet0/0/1
#
interface GigabitEthernet0/0/1.1
dot1q termination vid 4
ip address 10.0.4.254 255.255.255.0
arp broadcast enable
#
interface GigabitEthernet0/0/1.3
dot1q termination vid 8
ip address 10.0.8.254 255.255.255.0
arp broadcast enable
#
return
[R3]display current-configuration
[V200R007C00SPC600]
#
sysname R3
#
interface GigabitEthernet0/0/1
ip address 10.0.8.1 255.255.255.0
#
ip route-static 0.0.0.0 0.0.0.0 10.0.8.254
#
return
[S1]display current-configuration
!Software Version V200R008C00SPC500
#
sysname S1
#
vlan batch 4 8
#
interface GigabitEthernet0/0/1
port link-type access
port default vlan 4
#
interface GigabitEthernet0/0/2
port link-type trunk
port trunk allow-pass vlan 4 8
#
interface GigabitEthernet0/0/3
port link-type access
port default vlan 8
#
return
相关推荐
余~~185381628004 分钟前
矩阵碰一碰发视频之 API 接口接入技术开发全解析,支持OEM
网络·microsoft·php
loyd310 分钟前
【数据分析】5 设计不同业务分析框架
java·网络·数据分析
前端小菜鸡yy37 分钟前
流式输出方案:sse与websocket的使用
网络·websocket·网络协议·sse
我们的五年1 小时前
内网穿透:打破网络限制的利器
服务器·网络·生活
cd小白2 小时前
IO进程 day05
linux·服务器·c语言·网络·io进程
微尘hjx2 小时前
【Wireshark 02】抓包过滤方法
网络·测试工具·wireshark
心随_风动4 小时前
网络基础 —HTTP与HTTPS的基本介绍
网络·http·https
zl0_00_04 小时前
xss-lab
前端·网络·xss