我们之前介绍过如何配置openwrt工作在单臂路由模式(OpenWrt配置单臂路由模式),后来又介绍了基于openwrt开发的iStoreOS(将iStoreOS部署到VMware ESXi变成路由器),并且将其烧写进了VMware Edge 620上(VMware Edge 620神操作:刷入iStoreOS秒变全能企业级网关,轻松玩转多SSID),这样,我们就有了一台功能丰富的企业级路由器网关。
作为网关设备,就经常会遇到对接交换机的情况,我们刚刚介绍过Panabit如何配置和三层交换机配置VLAN互通(Panabit VLAN这样玩才高效:从透明网桥到网关模式的实战踩坑指南),今天我们就来简单看看iStoreOS如何和三层交换机配置VLAN互通。
首先,我们配置交换机的互联接口的链路类型为Trunk,并允许所有VLAN。
#
interface GigabitEthernet0/2
port link-mode bridge
port link-type trunk
port trunk permit vlan all
然后,我们新增几个VLAN,并创建对应的VLAN虚接口。
#
vlan 10 to 20
#
interface Vlan-interface10
ip address 172.17.10.1 255.255.255.0
#
interface Vlan-interface11
ip address 172.17.11.1 255.255.255.0
#
interface Vlan-interface12
ip address 172.17.12.1 255.255.255.0
#
interface Vlan-interface13
ip address 172.17.13.1 255.255.255.0
#
interface Vlan-interface14
ip address 172.17.14.1 255.255.255.0
#
interface Vlan-interface15
ip address 172.17.15.1 255.255.255.0
#
interface Vlan-interface16
ip address 172.17.16.1 255.255.255.0
#
interface Vlan-interface17
ip address 172.17.17.1 255.255.255.0
#
interface Vlan-interface18
ip address 172.17.18.1 255.255.255.0
#
interface Vlan-interface19
ip address 172.17.19.1 255.255.255.0
#
interface Vlan-interface20
ip address 172.17.20.1 255.255.255.0
然后我们到iStoreOS上进行配置,在【网络】下的【接口】页面,切换到【设备】页签,点击页面底部的【添加设备配置】。
在添加设备配置页面,设备类型选择【VLAN(802.1q)】,注意区分【VLAN(802.1ad)】类型,802.1q是基础VLAN,而802.1ad是QinQ,用于多层标签场景;基础设备我发现有两种选择方式,一种是使用默认的br-lan虚拟设备,另一种是选择物理接口,我们先使用br-lan虚拟设备;VLAN ID输入我们打算配置的VLAN 10,自动带出的设备名为br-lan.10,可以按需进行调整。因为不想使用IPv6,我将【启用IPv6】配置成了【已禁用】。最后点击【保存】完成添加。
重复添加设备配置这一步,不同的是,我们本次基础设备选择接线的【eth2】,VLAN ID配置为11,设备名自动配置为eth2.11,同样将【启用IPv6】配置成【已禁用】。最后点击【保存】完成添加。
添加好的两个设备如下所示:
接下来,我们切换到【接口】页签,点击【添加新接口】按钮。在对话框中,配置名称为VLAN10,协议选择【静态地址】,设备选择刚刚添加的【br-lan.10】;点击【创建接口】。
然后,在【常规设置】页签,为接口配置一个IPv4地址和子网掩码。
切换到【防火墙设置】页签,将接口分配到防火墙区域lan;点击【保存】。
重复添加新接口的操作,再新增一个VLAN 11的接口,配置IP地址为172.17.11.11。
添加完成之后,我们到交换机上试一下互通情况。
经测试,VLAN 10与VLAN 11间的通信均正常,Ping丢包率为0%,验证配置成功。那基础设备选择接线的物理接口和虚拟设备br-lan有什么区别呢?我测试了一下,目前只发现当基础设备选择虚拟设备br-lan时,配置接口的时候可以不配置防火墙区域;而选择接线的物理接口,则必须配置防火墙区域才能互通。
当然,如果你更喜欢使用命令行配置,也可以修改配置文件/etc/config/network,添加以下配置:
config device
option type '8021q'
option ifname 'br-lan'
option vid '10'
option name 'br-lan.10'
option ipv6 '0'
config device
option type '8021q'
option ifname 'eth2'
option vid '11'
option name 'eth2.11'
option ipv6 '0'
config interface 'VLAN10'
option proto 'static'
option device 'br-lan.10'
option ipaddr '172.17.10.10'
option netmask '255.255.255.0'
config interface 'VLAN11'
option proto 'static'
option device 'eth2.11'
option ipaddr '172.17.11.11'
option netmask '255.255.255.0'
同时记得在防火墙配置文件/etc/config/firewall中添加新增的接口。
config zone
option name 'lan'
option input 'ACCEPT'
option output 'ACCEPT'
option forward 'ACCEPT'
option masq '1'
list network 'lan'
list network 'VLAN10'
list network 'VLAN11'
最后重启网络服务就可以了。
简简单单,VLAN终结配置成功。
**推荐阅读***
原文始发于微信公众号(铁军哥):OpenWrt高级玩法:iStoreOS多VLAN划分+跨设备VLAN通信配置指南
- 左青龙
- 微信扫一扫
-
- 右白虎
- 微信扫一扫
-
评论