1、华为路由器单臂路由实例需求:在局域网中, 通过交换机上配置 VLAN 可以减少主机通信广播域的范围,当 VLAN 之间有部分主机需要通信,但交换机不支持三层交换时 ,可以采用一台支持 802.1Q 的路由器实现 VLAN 的互通.这需要在以太口上建立子接口 ,分配 IP 地址作为该 VLAN 的网关,同时启动 802.1Q.组网:路由器 E0 端口与交换机的上行 trunk 端口(第 24 端口)相连,交换机下行口划分 3 个 VLAN,带若干主机.拓扑图如下: 1.路由器的配置RouterRouterinter e0Router-Ethernet0ip add 10.0.0.1 255.25
2、5.255.0 Router-Ethernet0inter e0.1 /定义子接口 E0.1Router-Ethernet0.1ip add 172.16.1.1 255.255.255.0Router-Ethernet0.1vlan-type dot1q vid 1 /指定以太网子接口属于 VLAN1,此命令应用在以太网子接口上。只有配置了该命令之后,以太网子接口才会根据配置的 VLAN ID 号在以太网帧头中嵌入VLAN 标签,与该网口相连的交换机接口才能正确处理接收到的帧。Router-Ethernet0.1inter e0.2 /定义子接口 E0.2Router-Ethernet0.2
3、ip add 172.16.2.1 255.255.255.0Router-Ethernet0.2vlan-type dot1q vid 2 /指定以太网子接口属于 VLAN2Router-Ethernet0.2inter e0.3 /定义子接口 E0.3Router-Ethernet0.3ip add 172.16.3.1 255.255.255.0Router-Ethernet0.3vlan-type dot1q vid 3 /指定以太网子接口属于 VLAN3Router-Ethernet0.3inter e0Router-Ethernet0undo shut% Interface Eth
4、ernet0 is upRouter-Ethernet0 /用网线将 E0 端口连到 S3026 第 24 端口%19:46:32: Interface Ethernet0 changed state to UP%19:46:32: Line protocol ip on interface Ethernet0, changed state to UP%19:46:32: Line protocol ip on interface Ethernet0.1, changed state to UP%19:46:32: Line protocol ip on interface Ethernet0
5、.2, changed state to UP%19:46:32: Line protocol ip on interface Ethernet0.3, changed state to UP2.交换机的配置sysEnter system view , return user view with Ctrl+Z.Quidwayvlan 1Quidway-vlan1vlan 2Quidway-vlan2port ethernet 0/17 to eth 0/19 eth 0/22 /将第 17 至 19 端口,和第 22 端口加入 VLAN2Quidway-vlan2vlan 3Quidway-v
6、lan3port eth 0/21 /将第 21 端口加入 VLAN2Quidway-vlan3inter e0/24Quidway-Ethernet0/24port link-type trunk /将第 24 端口设为 trunk 口Quidway-Ethernet0/24port trunk permit vlan all /允许所有 VLAN 流量通过Please wait. Done.Quidway-Ethernet0/24dis port trunk /检验 TRUNK 口配置Now, the following trunking ports exist:Ethernet0/24
7、Quidway-Ethernet0/24dis vlan 2 /检验 VLAN2 的配置VLAN ID: 2VLAN Type: staticRoute Interface: not configuredDescription: VLAN 0002Tagged Ports: Ethernet0/24 Untagged Ports: Ethernet0/17 Ethernet0/18 Ethernet0/19 Ethernet0/22 Quidway-Ethernet0/24dis vlan 3 /检验 VLAN3 的配置VLAN ID: 3VLAN Type: staticRoute Inte
8、rface: not configuredDescription: VLAN 0003Tagged Ports: Ethernet0/24 Untagged Ports: Ethernet0/21 3.在工作站上检查网络是否连通。此工作站连接 S3026 第 21 端口,属于 VLAN2。C:Documents and SettingsAdministratoripconfigWindows 2000 IP ConfigurationEthernet adapter 本地连接:Connection-specific DNS Suffix . :IP Address. . . . . . . .
9、 . . . . : 172.16.2.22Subnet Mask . . . . . . . . . . . : 255.255.255.0Default Gateway . . . . . . . . . : 172.16.2.1C:Documents and SettingsAdministratorping 172.16.3.1Pinging 172.16.3.1 with 32 bytes of data:Reply from 172.16.3.1: bytes=32 timesysEnter system view , return user view with Ctrl+Z.Qu
10、idwayvlan 1Quidway-vlan1vlan 2Quidway-vlan2port ethernet 0/17 to eth 0/19 eth 0/22Quidway-vlan2vlan 3Quidway-vlan3port eth 0/18Quidway-vlan3inter e0/24Quidway-Ethernet0/24port link-type trunkQuidway-Ethernet0/24port trunk permit vlan allPlease wait. Done.Quidway-Ethernet0/24dis port trunkNow, the fo
11、llowing trunking ports exist:Ethernet0/24 Quidway-Ethernet0/24dis vlan 2VLAN ID: 2VLAN Type: staticRoute Interface: not configuredDescription: VLAN 0002Tagged Ports: Ethernet0/24 Untagged Ports: Ethernet0/17 Ethernet0/19 Ethernet0/22 Quidway-Ethernet0/24dis vlan 3VLAN ID: 3VLAN Type: staticRoute Interface: not configuredDescription: VLAN 0003Tagged Ports: Ethernet0/24 Untagged Ports: Ethernet0/18 Quidway-Ethernet0/24%Oct 30 20:02:28 2003 Quidway L2INF/5/PORT LINK STATUS CHANGE:Slot=1; Ethernet0/17: turns into UP state