ros端口映射几种方法

更新时间:2024-02-03 03:29:01 阅读量: 教育文库 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

教程:ROS如何设置ADSL的端口映射(端口转发)

ADSL的外网IP是不固定的,每次重新拨号都会被重新分配个IP,做端口映射的时候就不太好弄,网上找了很久也没有能用的方案,研究了1天,终于搞定了,分享出来可以给需要的人参考。

1. 打开Winbox->New Terminal,执行如下命令:/ ip firewall nat add action=masquerade chain=srcnat disabled=no out-interface=pppoe-out1

/ ip firewall nat add action=dst-nat chain=dstnat comment=web80 disabled=no dst-address=

IP

dst-address-type=local

dst-port=80

protocol=tcp

to-addresses=192.168.0.8(DNS服务器IP) to-ports=802. 复制如下Script,名为ADSL_YingShe::global newip [ /ip address get address ] :set newip [:pick $newip 0 [:find $newip \:global oldip dst-address] :if ($newip != $oldip) do={ :log info dst-address=$newip] :log info \映射修改完毕\我这里设置了3个端口

3. 最后设置事务

System->Scheduler,Interval设置脚本执行时间间隔,我设置为2分钟。On Event里填写::execute ADSL_YingShe

至此设置完成,应该就可以用了,下面简单说一下脚本的作用: 1. 搜索PPPOE端口的外网IP地址

2. 搜索名为: \端口为: 80的NAT 规则外网IP地址与PPPOE端口IP作比较。

3. 比较如果不一致,说明外网IP变了,则把NAT 规则外网IP地址设置为PPPOE端口实际外网IP 4. 2分钟(可设置)查询一次,如果间隔设置太大,IP更新速度就慢,设置太小,路由器的负荷就会大。所以应根据需要合理设置。

真是死脑筋,固定IP会,不固定的就不会了? 不固定的外网IP不写就是了

进入winbox

打开终端(New Terminal) / ip firewall nat add chain=dstnat protocol=tcp

dst-port=60000 action=dst-nat \\

to-addresses=192.168.0.200 to-ports=60000 comment=\disabled=no

照抄,把端口改成你要映射的就行了

/ip firewall nat add chain=dstnat protocol=tcp dst-port=9912 action=dst-nat \\

to-addresses=192.168.0.5 to-ports=9912 \\

comment=\网维ADSL端口映射--用户发出请求\disabled=no add chain=srcnat

src-address=192.168.0.5 protocol=tcp \\ src-port=9912

action=masquerade

comment=\网维ADSL端口映射--服务器回应\disabled=no

本文来源:https://www.bwwdw.com/article/oktw.html

Top