①第一种设置方法,这种方法没有回流,因此设置后,内网是无法打开,外网可以打开,如果需要内外网都可以打开的,可以直接看第二种设置方法。
一、映射端口,打开IP –> Firewall –> NAT
1.创建一条dstnat策略,其中“Chain”设为dstnat,“Protocol”设为6(tcp),“Dst.Port”设为5000(即外网端口号,可自定义),”In.Interface”设置为pppoe-out1
2.“Action”设为dst-nat,“To Address”设为10.10.10.109(这个地址就是我要映射的NAS的内网IP地址),“To Ports”设为5000(即内网端口号,这个端口号是你设备服务固定的端口号)。

②第二种设置方法,具备回流,内外网均可打开
一、映射端口,打开IP –> Firewall –> NAT
1.创建一条dstnat策略,其中“Chain”设为dstnat,“Dst.Address”设为ADSL获取到的公网IP地址,“Protocol”设为6(tcp),“Dst.Port”设为5000(即外网端口号,可自定义)

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

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

下面代码部分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] }

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

到此端口映射已经完成,内网外网都可以访问。
继续阅读
评论