4-19
Saturday
标签
梦涛笔记

ROS通过aliyun域名解析实现DDNS脚本

ROS 发布时间:2025-03-29 13:51:38
#aliyun Access Key
:local id "key"
:local secret "secret"

#domain
:local domain "your.domain.com"


#PPPoE-out
:local pppoe "pppoe-out1"

#阿里云DDNS服务器:

:local ipaddr [/ip address get [/ip address find interface=$pppoe] address]
:set ipaddr [:pick $ipaddr 0 ([len $ipaddr] -3)]
#:log info $ipaddr;
:local result [/tool fetch url="https://www.zhisg.com/route.php/ddns/ali/set\?id=$id&secret=$secret&domain=$domain&ip=$ipaddr" as-value output=user];
:log info $result;


#:global ddnspool "ipv6"
#:global ddnsinterface "bridge"
#:global ddnsinterface "6to4-henet"
#:global ddnsinterface "pppoe-out1"
#:global ddnsinterface "ether6"

# Define Global Variables
:global ddnsip
:global ddnslastip
:if ([ :typeof $ddnslastip ] = nil ) do={ :global ddnslastip "0" }


# Define Local Variables
:local int

# Loop thru interfaces and look for ones containing
# default gateways without routing-marks
:if ([ :typeof $ddnsinterface ] != "str" ) do={
  :foreach int in=[ /ipv6 address find global ] do={
    :local testip [ /ipv6 address get $int address ]
    :if ($testip in "fe80::/10" || $testip in "fc00::/7") do={
    } else={
      :global ddnsip $testip
    }
  }
} else={
  :if ([ :typeof $ddnspool ] != "str" ) do={
    # Grab the current Global IP address on that interface.
    :foreach int in=[ /ipv6 address find interface=$ddnsinterface global ] do={
      :local testip [ /ipv6 address get $int address ]
      :if ($testip in "fe80::/10" || $testip in "fc00::/7") do={
      } else={
        :global ddnsip $testip
      }
    }
  } else={
    # Grab the current Global IP address on that interface from spec ip pool.
    :global ddnsip [ /ipv6 address get [ /ipv6 address find interface=$ddnsinterface  from-pool=$ddnspool ] address ]
  }
}

# Did we get an IP address to compare?
:if ([ :typeof $ddnsip ] = nil ) do={
   :log info ("DynDNS: No ip address present on please check.")
} else={
  :log info ("DynDNS: check IPv6 UPDATE " . $ddnsip)
#  :if ($ddnsip != $ddnslastip) do={
:local result [/tool fetch url="https://www.zhisg.com/route.php/ddns/ali/set\?id=$id&secret=$secret&domain=$domain&ip=$ddnsip&type=AAAA" as-value output=user];
:log info $result;    
    :global ddnslastip $ddnsip
#  }
}


使用路由表为VPN加速

ROS 路由 发布时间:2025-03-14 14:14:57

由于连接上VPN后,默认所有流量都会走VPN线路,为了访问国内网络速度不变,可以使用设置路由表的方法解决,但是为了使用VPN加密及匿名的话,就没有必要设置路由表了。
其中Google项目在这里http://code.google.com/p/chnroutes,
下载相应的版本,其中包括2个文件,vpnup.bat文件是添加路由表文件,vpndown.bat文件是删除路由表文件。
下载后运行出错,需要编辑下vpnup.bat
在for /F “tokens=3” %%* in (‘route print ^| findstr “\<0.0.0.0\>”‘) do set “gw=%%*” 后面添加一行
set gw=192.168.1.1

ROS软路由器的多线路转发规则

ROS 发布时间:2025-03-14 14:05:27

基层路由器设置多线互通时比较麻烦,里添加NAT规则才行,在winbox里的IP-防火墙,标记器里添加规则。
先进先出,三条线路的,步骤还不是很明白,先把截图存起来。

image.png

image.png

image.png

image.png


———————————四线-两个电信是同网关的—————————————–

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png

image.png


ROS全套软件汉化包及证书以及多线配置备份

ROS 发布时间:2025-03-14 13:53:09

常用命令:
/interface print 显示网卡列表
/ip address print 打印 IP 地址列表
/ip address remove 2 删除没用的列表
/ip address add address 10.0.0.1/24 interface ether1

ROS 千兆多网卡(lan)桥接 =路由器+多口千兆交换机

路由 ROS 发布时间:2025-03-14 13:50:19

有了ROS软路由的朋友,家里有个局域网还要买个多口的千兆的交换机会增加不少的成本。如果ROS软路由的电脑主板上有足购的PCI插槽或者集成二口千兆网卡的最好,那么按照下面的方法能实现多口千兆交换机的功能。一般家用的都是用ADSL拔号上网的,那么wan的网卡就用intel的100兆网卡即可。假如有五块千兆网卡组成lan,即ether1,ether2,ether3,ether4,ether5,ether6(接宽带的wan口)那么:

1、先建立一个名为mybridge的桥

interface bridge add name=”mybridge” disable=no

2、将ether1-ether5的五块网卡加入到这个新建的桥中

interface bridge port add interface=ether1 bridge=mybridge
interface bridge port add interface=ether2 bridge=mybridge
interface bridge port add interface=ether3 bridge=mybridge
interface bridge port add interface=ether4 bridge=mybridge
interface bridge port add interface=ether5 bridge=mybridge

ok,五块已经组成桥

3、设置桥的IP地址,如192.168.1.1

ip address add address 192.168.1.1/24 interface=mybridge

这时,可以用winbox连接ROS了,其他的设置皆可在winbox 里操作了。

5个lan口就像交换机一样使用了,性能比普通的千兆交换机要好得多。


ROS路由共享上网及IP显示问题

路由 ROS 发布时间:2025-03-14 13:47:37

路由器设置好后,需要设置NAT规则才可以共享上网,最简单的办法就是添加srcnat规则,masquerade处理就行了。

但是这样外网访问的时候,服务器获取的IP都会是内网网关IP(192.168.1.1),所以需要做如下处理即可正常。

当然如果用NAT的方式共享上网就不存在这些问题。

image.png

image.png

image.png

image.png

ROS 限速脚本

ROS 发布时间:2025-03-13 20:15:04
#ROS 5

for myip from 2 to 254 do={/queue simple add name=("限192.168.1." . $myip . "") target-address=("192.168.1." . $myip . "/32") limit-at=0/0 max-limit=5120000/8192000 }
#ROS 6

:for myip from 1 to 254 do={/queue simple add name=("6." . $myip . "") dst=("192.168.6." . $myip . "/32")  max-limit=204800000/30096000 target=0.0.0.0/0 }



ROS采用NAT共享上网方式

ROS 发布时间:2025-03-13 19:35:25

大家都知道,ROS有个特别的Action:masquerade,用于共享上网,但这个方式上网率效比NAT方式慢。
其实设置NAT共享上网也很简单,只要设置如下:
如果是多线,只需重复设置几条,对应好Out. Interface 及To Address的IP即可。
当然,设置完别忘了设置网关路由。

image.png

image.png