方法1(IP方法)
/ ip firewall nat
add chain=dstnat 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 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
==================================================================

方法2(接口方法)
/ 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
==================================================================
方法3(固定IP+脚本更新IP方法,通过注释判断comment=”mapping”)

/ 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

转载于:https://blog.51cto.com/xfenoo/1603685

ROS做端口映射DDNS的N个做法详细教程相关推荐

  1. Linux下用iptables做端口映射

    Linux下用iptables做端口映射详细过程 在CentOS5.4上用iptables配置了端口映射,讲述详细的配置过程,供大家参考. [实现功能] server-A eth0      119. ...

  2. xstream 数字映射不上去_6个做端口映射的步骤,外网访问内网,菜鸟也能做?

    端口映射通俗来说就是将外网主机的IP地址端口映射到内网中一台机器,提供相应的服务.内网相通,电因特网对外开放服务或者接收大数据,都需要端口映射. 首先,想要做好端口映射,确定路由器,清楚的认识软件需要 ...

  3. 如何在路由器上做端口映射

    假设现在外网有一台ADSL直接拨号上网的电脑,所获得的是公网IP.然后它想访问局域网内的电脑上面的网站,那么就需要在路由器上做端口映射.在路由器上做端口映射的具体规则是:将所有发向自己端口的数据,都转 ...

  4. 不在路由器上做端口映射,如何访问局域网内网站

    假设现在外网有一台ADSL直接拨号上网的电脑,所获得的是公网IP.然后它想访问局域网内的电脑上面的网站,那么就需要在路由器上做端口映射.在路由器上做端口映射的具体规则是:将所有发向自己端口的数据,都转 ...

  5. 端口映射的作用?如何在路由器上做端口映射

    一.端口映射作用 路由器中设置端口映射的主要作用,就是让Internet上的其他用户,可以访问你路由器下面电脑中的数据(软件.文件). 当家里的电脑使用路由器上网后,在Internet下的其它电脑.手 ...

  6. 什么是端口映射?做端口映射要领

    当今的计算机办公相对来说是一个很遍及的工作了,对于这一点是毋庸置疑的.有少许工作朋友们喜欢在家里实现,不过一上班就有可能忘记了带出来,即使是放在u盘里,也有可能出现丧失的征象.那么对付这样的环境,少许 ...

  7. 华为USG设备做端口映射

    NAT原理 NAT(Network Address Translation)网络地址转换技术,在企业内通常使用私网IP,Internet上使用公网IP,使用私网IP的计算机需要访问Internet时就 ...

  8. 二级路由器如何做端口映射

    上网的时分经常会遇到这样的情况,一个路由器不能够满意运用需求;为了解决这个问题,能够在增加一个二级路由器,对网络进行扩展.那么二级路由器怎样设置呢?主要把第一个路由器设置好能够上网,第二个路由器封闭D ...

  9. 固定ip和动态ip的区别?固定ip怎么做端口映射?

    相信很多人分不清什么是固定ip,什么是动态ip,两者比较容易混淆.其实固定ip和动态ip还是有很大区别的!今天小编跟大家说说两者的区别,只有固定ip时选择什么样的端口映射方案. 固定ip和动态ip有什 ...

  10. 华三路由器做端口映射配置

    华三路由器的端口映射配置方法如下: 打开浏览器,在地址栏中输入华三路由器的 IP 地址,然后按回车键登录路由器的管理界面. 在管理界面中,选择"高级设置",然后选择"端口 ...

最新文章

  1. SMOTE算法代码实现-机器学习
  2. opencv jni Android 实例笔记
  3. window清理垃圾
  4. 服务器端的根目录放置文件,放置在网站根目录下
  5. SD和TF两种卡片的区别
  6. java 内存空间_怎样用java实现存储空间动态分配
  7. 29. Divide Two Integers
  8. java 查看虚拟机状态_深入理解java虚拟机学习笔记(四)虚拟机性能监控与故障处理工具...
  9. 心里话:技术人需要及时明白的道理
  10. cvi调用matlab dll,cvi通过artix调用matlab
  11. 计算机组装与维护英语怎么说,计算机组装与维护-复习题(国外英语资料).doc
  12. sap系统ftp服务器下文件,sap ftp服务器
  13. PCS2021:VVC基于神经网络改进SAO
  14. 逐行解析linux kernel NIC驱动
  15. 动态数据的表格页面展示
  16. 电脑版微信提示音mp3_安卓充电提示音修改教程,可以自定义哦~
  17. idc数据中心机房机柜收费标准
  18. Unity Shader PostProcessing - 8 - Bloom 泛光
  19. 快手挂小黄车和快手小店有什么区别?如何开通快手小店?
  20. Hadoop No FileSystem for scheme “hdfs“ 客户端环境变量配置

热门文章

  1. 关于NLSSORT和NLS_SORT的用法
  2. OKR 与绩效考核结合的推进行业案例:医药行业
  3. 项目管理体验营day3:项目管理之沟通技巧
  4. Cadence 17.4 PSpice 学习笔记
  5. python实现新年倒计时代码
  6. java实现网页结构分析列表发现
  7. 计算机网络及光纤通信实验教程,电子科技大学光纤通信视频教程
  8. matlab 空间解析几何,Matlab 数学软件包在向量代数—空间解析几何中的应用
  9. centos 切换终端_centos进入不同终端的几种方法
  10. project实操——项目实例