Access to OpenWrt web interface from WAN side network

现状:OpenWrt以软路由的形式安装在esxi虚拟机中,分配有4个实体网口(笔记本连接在这4个实体网口上),虚拟机安装在HP gen8上,gen8连接在天翼光猫上,OpenWrt相当于旁路由。台式机也接在同一天翼光猫上。

Present situation: OpenWrt is installed in the esxi virtual machine, and 4 physical network ports are allocated (the notebook is connected to these 4 physical network ports), the virtual machine is installed on HP gen8, and gen8 is connected to the main route.OpenWrt is equivalent to bypass routing.One PC was also connected to the main route.

光猫网关:192.168.1.1 台式机ip:192.168.1.10 openwrt ip:192.168.1.11

openwrt作为旁路由,自身网关:192.168.200.1 笔记本ip:192.168.200.2

Main route Gateway:192.168.1.1 PC IP:ip:192.168.1.10 openwrt ip:192.168.1.11

OpenWrt as bypass routing,Gateway:192.168.200.1 notebook ip:192.168.200.2

需求:通过台式机,能够访问openwrt的web管理地址192.168.200.1,方便使用,不用每次都开笔记本,进一步通过公网能够访问openwrt的web管理地址192.168.200.1的web管理地址(开放给公网实际上是不安全的,同时需要有公网ip,以及动态DNS解析)

Requirements: through the desktop, can access to web management address 192.168.200.1 of OpenWrt.Don't need to open a notebook every time.

开始 | begin:

思路:台式机访问openwrt的web管理界面,实际上,就是上一级网路访问下一级网络。台式机(192.168.1.10)能够直接访问openwrt(192.168.1.11),只需要设置将台式机对openwrt的访问,转发到openwrt内部(192.168.200.1)这个地址上,打开放防火墙即可。

1、登录openwrt---网络---防火墙---常规设置---区域

1、openwrt---Network---Firewall---General---Zones

当然,也可以设置全部都开放,我这个在局域网内,不存在安全问题。各个版本的openwrt界面布局,颜色上可能有些许不同,但是内容核心是相同的。比如:

2、网络---防火墙---端口转发

2、Network---Firewall---Port Forwards

台式机访问openwrt内部,是要经过它的lan口(现实世界中,台式机与openwrt也是lan口直接连接)。所以将台式机对openwrt(192.168.1.11)的某个端口的访问(这里是8000),转发到openwrt内部192.168.100.1的80端口上(平常访问没有输入80端口,是默认就是80端口)

3、网络---防火墙---流量规则

3、Network---Firewall---Traffic Rules

允许8000端口的流量进入

此时,台式机通过192.168.1.11:8000就已经能够访问OpenWrt的web管理地址了。但是有两个小问题:

1、不知道OpenWrt在主路由上得IP地址:

登录OpenWrt---状态---网络---ipv4 wan状态:地址:192.168.1.11这里就是它在主路由上的IP地址。

2、每次重启openwrt后,openwrt在主路由下的IP地址一直变化,可能下次就不是192.168.1.11这个ip了,防火墙,端口转发都需要重新设置,太过麻烦。可以将openwrt的wan连接设置为固定ip(类似于台式机设置固定ip),将ip固定成192.168.1.11.

登录openwrt---网络---接口---wan

依次修改:协议、ipv4地址修改为192.168.1.11(这里可以设置成自己想要的地址,只要防火墙和端口转发配合设置即可)、ipv4子网掩码、ipv4网关(主路由的网关地址,以实际网关地址为准)