用户工具

站点工具


irouter:net:vlan_l3fwd

返回首页

企业VLAN网络三层转发

三层交换机上划分有多个VLAN, 路由上不划分VLAN,接交换机的普通端口(VLAN1)。

另外参考:

网络拓扑


路由上的配置


1. 对三层下的VLAN 添加 NAT 规则

网络-》LAN(局域网),在对应的LAN下面添加:

默认只有和LAN同网段的IP才能上网,加入后三层下的客户机才能正常上网。

2. 添加静态路由, 让VLAN下的客户机和路由能互通

进入“路由/NAT”-》“静态路由”

启用“静态路由”,依次添加4条规则(每个VLAN一条),如下:

最后的规则如下:

点击“静态路由状态“,确认静态路由正常

注:如果192.168.X.X网段没有其他用途,可以只添加一条规则(目的网络 192.168.0.0/16)

三层交换机上的配置


这里以H3C S5024 为例

vlan 10 20 30 40

## 默认VLAN1 IP 地址
interface Vlanif1
 ip address 172.16.0.1 255.255.255.0

## VLAN10 IP 地址
interface Vlanif10
 ip address 192.168.10.1 255.255.255.0

## VLAN20 IP 地址
interface Vlanif20
 ip address 192.168.30.1 255.255.255.0   

## VLAN30 IP 地址                                         
interface Vlanif30                        
 ip address 192.168.30.1 255.255.255.0   

## VLAN40 IP 地址                                         
interface Vlanif40                        
 ip address 192.168.40.1 255.255.255.0   

## 端口1-5 在VLAN-10中
#---------------------------------------
interface GigabitEthernet0/0/1
 port link-type access
 port default vlan 10
#
... 省略 ...
#
interface GigabitEthernet0/0/5
 port link-type access
 port default vlan 10
#---------------------------------------

## 端口6-10 在VLAN-20中
#---------------------------------------
interface GigabitEthernet0/0/6
 port link-type access
 port default vlan 20
#
... 省略 ...
#
interface GigabitEthernet0/0/10
 port link-type access
 port default vlan 20
#---------------------------------------

## 端口11-15 在VLAN-30中
#---------------------------------------
interface GigabitEthernet0/0/11
 port link-type access
 port default vlan 30
#
... 省略 ...
#
interface GigabitEthernet0/0/15
 port link-type access
 port default vlan 30
#---------------------------------------

## 端口16-20 在VLAN-40中
#---------------------------------------
interface GigabitEthernet0/0/16
 port link-type access
 port default vlan 40
#
... 省略 ...
#
interface GigabitEthernet0/0/20
 port link-type access
 port default vlan 40
#---------------------------------------

## 其他端口在默认VLAN1中
#---------------------------------------
#
interface GigabitEthernet0/0/21
... 省略 ...
#
interface GigabitEthernet0/0/24
#
#---------------------------------------

## 交换机的默认路由(设为路由的LAN1口的IP)
ip route-static 0.0.0.0 0.0.0.0 172.16.0.2

注:路由接在21~24中的任一默认VLAN1端口

网络诊断及测试


1. 内网互通测试

使用任一一台电脑(IP设为和路由LAN口相同网段 172.16.0.X)

接入三层交换机的任一默认VLAN1端口(21-24口),进入路由-》“工具”-》“PING测试”,依次

  • PING 交换机的VLAN1的IP地址,如不通,检查交换机的vlan1接口ip设置
  • PING 交换机的其他各个VLAN(10~40)的IP地址, 如不通,检查路由上的静态路由是否正常,或交换机的vlan接口的ip设置
  • PING 交换机下某一VLAN下的客户机的IP,比如 VLAN10下的192.168.10.2,如果不通,检查交换机上的默认路由是否设置正确

2. 访问外网测试

在VLAN下的客户机电脑上(比如VLAN10中的192.168.10.2),访问外网,如果不通,检查

  • 其网关是否设为三层交换机对应VLAN的接口IP(192.168.10.1)
  • 路由上是否针对VLAN网络添加了 NAT 策略

三层转发方案的优缺点


优点:内网不同VLAN之间的数据直接通过交换机转发,对路由压力小。

缺点:

  • 不能使用路由上的DHCP为VLAN下的客户机分配IP
  • VLAN 下的客户机无法通过PPPoE拨号穿透三层交换机到路由
  • 路由上无法获得VLAN下客户机的MAC地址

另外参考:企业网络VLAN穿透部署

锐捷三层交换机配置

Ruijie>en 
Ruijie#config terminal
Ruijie(config)#interface TenGigabitEthernet 0/31                                                 
Ruijie(config-if-TenGigabitEthernet 0/31)#switchport mode trunk  
Ruijie(config-if-TenGigabitEthernet 0/31)#switchport trunk allowed vlan all 

H3C S5130 配置WEB登陆

1. 建立用户名密码

local-user admin class manage
password simple admin123
service-type telnet http https
authorization-attribute user-role level-15 
authorization-attribute user-role network-admin
quit

2. 启用服务

[H3C]telnet server enable
[H3C]ip http enable
[H3C]ip https enable

3. 建立接口地址:

[H3C]interface Vlan-interface 1
ip address 192.168.0.237 255.255.255.0

4. 配置虚接口:

[H3C]line vty 0 63
authentication-mode scheme
quit
[H3C]quit
<H3C>save

这几步配置完成,就可以通过telnet、web方式登录了。

irouter/net/vlan_l3fwd.txt · 最后更改: 2023/11/09 09:12 由 muddyboot

Copyright © 2014-2020 版权所有 (MoreQuick Networs Co., Ltd. All rights reserved)
本系统由 秒开 iRouter & 在阿里云上强力驱动