前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >ROS端口映射的几个做法

ROS端口映射的几个做法

原创
作者头像
it妹
修改2019-10-25 18:03:31
6.5K0
修改2019-10-25 18:03:31
举报
文章被收录于专栏:iis7

方法1(接口方法) / ip firewall nat add chain=dstnat in-interface=adsl接口名 protocol=tcp dst-port=要开放的外网端口 \ action=dst-nat to-addresses=要映射的内网IP地址 to-ports=要映射的内网端口 comment=”” \ disabled=no

列如:映射80端口到192.168.200的80端口 / ip firewall nat add chain=dstnat in-interface=pppoe-out1 protocol=tcp dst-port=80 \ action=dst-nat to-addresses=192.168.1.200 to-ports=80 comment=”mapping” \ disabled=no

方法2(使用iis7监控工具

IIS7服务器监控工具该软件风格简约,操作简单,删除系统缓存,重启服务器,修改服务器账号密码,修复服务器复制功能等,也可以一键开启关闭MYSQL和503错误的监控,省去了繁琐的操作步骤,一键完成。也可以直接修改远程端口范围,省去繁琐步骤。

/ ip firewall nat add chain=dstnat dst-address=10.10.10.10 protocol=tcp dst-port=80 \ action=dst-nat to-addresses=192.168.200 to-ports=80 comment=”mapping” \ disabled=no #刷新脚本(此脚本放到调度程序里面定时运行来更新ADSL的IP到映射的IP) #调度程序位置在 system – scheduler :local oldip :local newip :set newip [/ip address get [/ip address find dynamic=yes interface=pppoe-out1 ] address ] :put $newip :set oldip [/ip firewall nat get [find comment=mapping] dst-address ] :if ($newip != $oldip) do={ /ip firewall nat set [find comment=mapping] dst-address=$newip }

或在终端运行以下代码 add name=”schedule111″ \ on-event=”#刷新脚本(此脚本放到调度程序里面定时运行来更新ADSL的IP到映射的IP)\

\n:local oldip \n:local newip \n:set newip \[/ip address get \[/ip \ address find dynamic=yes interface=pppoe-out1 \] address \] \n:put \ \$newip \n:set oldip \[/ip firewall nat get \[find comment=mapping\] \ dst-address \] \n:if (\$newip != \$oldip) do={ \n/ip firewall nat \ set \[find comment=mapping\] dst-address=\$newip \n}” \ start-date=jan/01/1970 start-time=00:00:00 interval=30s comment=”” \ disabled=no

运行后会自动在调度程序里添加上面那个脚本(默认30秒运行一次) 在调度程序system – scheduler可以看到该脚本

================================================================== #IP伪装 / ip firewall nat add chain=srcnat action=masquerade comment=”” disabled=no

#IP回流 add chain=srcnat src-address=内网IP段/24 protocol=tcp action=masquerade \ comment=”” disabled=no

================================================================== 方法4(简单直接) / ip firewall nat add chain=dstnat src-address!=内网IP段 dst-address!=内网网关 protocol=tcp dst-port=要开放的外网端口 \ action=dst-nat to-addresses=要映射的内网IP地址 to-ports=要映射的内网端口 comment=”” \ disabled=no

列如:映射80端口到192.168.200的80端口 / ip firewall nat add chain=dstnat src-address!=192.168.1.0/24 dst-address!=192.168.1.1 protocol=tcp dst-port=80 \ action=dst-nat to-addresses=192.168.200 to-ports=80 comment=”mapping” \ disabled=no

动态域名解析: 3322解析脚本:

:local ednsuser “user” :local ednspass “password” :local ednshost “user.3322.org” :local ednsinterface “pppoe-out1″ :local members “http://members.3322.org/dyndns/update?system=dyndns” #:local members “http://members.dyndns.org/nic/update?” :local status :local status [/interface get [/interface find name=$ednsinterface] running] :if ($status!=false) do={ :local ednslastip [:resolve $ednshost] :if ([ :typeof $ednslastip ] = nil ) do={ :local ednslastip “0″ } :local ednsiph [ /ip address get [/ip address find interface=$ednsinterface ] address ] :local ednsip [:pick $ednsiph 0 [:find $ednsiph “/”]] :local ednsstr “&hostname=$ednshost&myip=$ednsip” :if ($ednslastip != $ednsip) do={/tool fetch url=($members . $ednsstr) mode=http user=$ednsuser password=$ednspass dst-path=$ednshost :delay 2 :local result [/file get $ednshost contents] :log info ($ednshost . ” ” .$result) /file remove $ednshost ; } }

changeip.net 脚本 :global ddnsuser “user”

:global ddnspass “pass”

:global ddnshost “user.changeip.net”

:global ddnsinterface “pppoe-out1″

:global ddnslastip

:global ddnsip [ /ip address get [/ip address find dynamic=yes interface=$ddnsinterface ] address ] :if ( [:typeof $ddnslastip]=”nothing” ) do={ :global ddnslastip 0.0.0.0/0 } :if ( [:typeof $ddnsip]=”nothing” ) do={ :log info (“DDNS: No ip address present on ” . $ddnsinterface . “, please check.”) } else={ :if ($ddnsip != $ddnslastip) do={ :log info “DDNS: Sending Update!” :log info [ /tool dns-update name=$ddnshost address=[:pick $ddnsip 0 [:find $ddnsip “/”] ] key-name=$ddnsuser key=$ddnspass ] :global ddnslastip $ddnsip } else={ :log info “DDNS: No change” } } :log info “DDNS: End”

论坛发现有人求助,如何定时启动脚本、定时开关某个或者某些防火墙。其实这是一个很简单的问题,大侠们都已 经很熟了。但还是有写菜鸟不怎么会,那我就来讲解下,非脚本-winbox下的操作。 1:定时任务。 我进入到system里找到schedule点开。点击+号,新建一个定时任务,如图

6 天前 上传 下载附件 (34.49 KB)

Strat Date 这里定义任务什么日期开始执行,如非特殊情况不需更改,除非你要这个任务100年后执行可以改为 Jan/01/2111 Start Time 这里定义任务开始的时间,例如下午3点执行,里面的值就是15:00:00 Interval 这里定义任务多久执行一次r,例如1天一次,里面的值就是1d 00:00:00 30分钟一次,里面的值就是00:30:00

到此我们清楚各项的含义,就可以组合起来使用了: 例1:我要执行一个任务每10秒执行一次 Strat Date 默认 Start Time 00:00:00 Interval 00:00:10 就可以了 如此定义每10分中执行一次,10小时一次,10天一次 项Interval值做相应的改变就是了

例2:我要执行一个任务每天8点20分执行 Strat Date 默认 Start Time 08:20:00 Interval 1d 00:00:00 就可以了 此时要注意的是,看看/system clock 里的时间是否准确,否者你会发现脚本执行的时间不是你定义的时间

脚本如何定时执行我们了解了,那么如何定时开关某些东西,运行某些东西呢?此时On Event:里面的内容就是肉 戏了我们都是知道在ros 里面大多地方我都可以为一些东西定义comment值来做说明,例如网卡、ip address、防火墙、 限速等等。commnet的意义不只是止于说明而已,通过comment的值我们可以开发很多脚本,例如论他很多大大开发 的PCC断线修改PCC参数脚本等都利用了comment值,当然我说这么多不是要讲comment的应用,嗯,淡定、淡定,我 想说的是,用这个comment值,我们配喝schedule来执行一些简单的开关而已、请大家淡定。 举例说明:(内容不包含已说明的如何定时执行) 例1:我要关闭一些防火墙,我们定义这些防火墙的comment值为 1 在On Event: 里写入 /ip firewall filter (进入防火墙目录) disable “1″ (关闭所有comment值为1的项,当然开启就是enable)

例2:我要关闭一些网卡,我们定义这些网卡的comment值为 1 在On Event: 里写入 /interface (进入网卡目录) disable “1″ (关闭所有comment值为1的网卡,当然开启就是enable)

例3:我要开启一些简单限速脚本,我们定义这些脚本的comment值为 1 在On Event: 里写入 /queues simple (进入简单限速目录) enable “1″ (开启所有comment值为1的简单限速) 例4:我要执行/system script 下名称为 xxx的脚本 在On Event: 里写入 xxx

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
作者已关闭评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
NAT 网关
NAT 网关(NAT Gateway)提供 IP 地址转换服务,为腾讯云内资源提供高性能的 Internet 访问服务。通过 NAT 网关,在腾讯云上的资源可以更安全的访问 Internet,保护私有网络信息不直接暴露公网;您也可以通过 NAT 网关实现海量的公网访问,最大支持1000万以上的并发连接数;NAT 网关还支持 IP 级流量管控,可实时查看流量数据,帮助您快速定位异常流量,排查网络故障。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档