ROS软路由 | ROS动态IP映射端口

RS 技术•随笔评论7,157字数 1089阅读3分37秒阅读模式
摘要①第一种设置方法,这种方法没有回流,因此设置后,内网是无法打开,外网可以打开,如果需要内外网都可以打开的,可以 […]

①第一种设置方法,这种方法没有回流,因此设置后,内网是无法打开,外网可以打开,如果需要内外网都可以打开的,可以直接看第二种设置方法。

一、映射端口,打开IP –> Firewall –> NAT

1.创建一条dstnat策略,其中“Chain”设为dstnat,“Protocol”设为6(tcp),“Dst.Port”设为5000(即外网端口号,可自定义),”In.Interface”设置为pppoe-out1

ROS软路由 | ROS动态IP映射端口

 

2.“Action”设为dst-nat,“To Address”设为10.10.10.109(这个地址就是我要映射的NAS的内网IP地址),“To Ports”设为5000(即内网端口号,这个端口号是你设备服务固定的端口号)。

ROS软路由 | ROS动态IP映射端口

②第二种设置方法,具备回流,内外网均可打开

一、映射端口,打开IP –> Firewall –> NAT

1.创建一条dstnat策略,其中“Chain”设为dstnat,“Dst.Address”设为ADSL获取到的公网IP地址,“Protocol”设为6(tcp),“Dst.Port”设为5000(即外网端口号,可自定义)

ROS软路由 | ROS动态IP映射端口

2.“Action”设为dst-nat,“To Address”设为10.10.10.109(这个地址就是我要映射的NAS的内网IP地址),“To Ports”设为5000(即内网端口号,这个端口号是你设备服务固定的端口号),选择“comment”,输入“5000”,名字可以随便输。

ROS软路由 | ROS动态IP映射端口

二、脚本更新公网动态IP地址,system –> script,新建一个脚本

ROS软路由 | ROS动态IP映射端口

下面代码部分pppoe-out1是创建的PPPoE拨号的名称,5000是策略的名称

:global ipaddr [/ip address get [/ip address find interface=pppoe-out1] address]
:set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)]
:global oldip [/ip firewall nat get [/ip firewall nat find comment="5000"] dst-address]
:if ($ipaddr != $oldip) do={
:log info [/ip firewall nat set [/ip firewall nat find comment="5000"] dst-address=$ipaddr]
}
ROS软路由 | ROS动态IP映射端口

三、新建一个计划,system –> schedule,Interval是间隔时间,其中的5000是上面创建的脚本名称

:execute 5000     #5000修改为你创建的脚本名称
ROS软路由 | ROS动态IP映射端口

到此端口映射已经完成,内网外网都可以访问。

继续阅读
 
RS
  • 本文由 RS 发表于 2019年3月5日 09:56:33
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定