RouterOS配置HE TunnelBroker

隧道去HE TunnelBroker申请,不再赘述。

配置隧道

/interface 6to4 add comment="Hurricane Electric IPv6 Tunnel Broker" disabled=no local-address=<Client IPv4 Address> mtu=1280 name=sit1 remote-address=<Server IPv4 Address>
/ipv6 route add comment="" disabled=no distance=1 dst-address=2000::/3 gateway=<Server IPv6 Address, without prefix> scope=30 target-scope=10

配置路由器IPv6

/ipv6 address
add address=<Server IPv6 Address> advertise=no disabled=no eui-64=no interface=sit1
add address=<Routed /64, 斜杠前加一个数字 1> advertise=yes interface=bridge

自动更新隧道客户端IPv4地址

脚本(不要直接在网页上复制,空行多余的空格会导致语法错误;点击右上角的复制按钮然后按 Ctrl+C 或 Command+C。)

# Update Hurricane Electric IPv6 Tunnel Client IPv4 address

# local HE Tunnel interface
:local HEtunnelinterface "sit1"
# Tunnel ID
:local HEtunnelid "12345"
# Username
:local HEuserid "example_user"
# Update key
:local HEupdatekey "abcdefghijkl"
# Your local ISP IPv4 interface
:local WANinterface "pppoe-out1"

# Don't really need to change
:local HEupdatehost "ipv4.tunnelbroker.net"
:local HEupdatepath "/nic/update"
:local outputfile ("HE-" . $HEtunnelid . ".txt")

# Internal processing below...
# ----------------------------------
:delay 15
:local HEipv4addr

# Get WAN interface IP address
:set HEipv4addr [/ip address get [/ip address find interface=$WANinterface] address]
:set HEipv4addr [:pick [:tostr $HEipv4addr] 0 [:find [:tostr $HEipv4addr] "/"]]

:if ([:len $HEipv4addr] = 0) do={
   :log error ("Could not get IP for interface " . $WANinterface)
   :error ("Could not get IP for interface " . $WANinterface)
}

# Update the HEtunnelinterface with WAN IP
/interface 6to4 {
   :if ([get ($HEtunnelinterface) local-address] != $HEipv4addr) do={
      :log info ("Updating " . $HEtunnelinterface . " local-address with new IP " . $HEipv4addr . "...")
      set ($HEtunnelinterface) local-address=$HEipv4addr
   }
}

:log info ("Updating IPv6 Tunnel " . $HEtunnelid . " Client IPv4 address to new IP " . $HEipv4addr . "...")
/tool fetch mode=http \
                  host=($HEupdatehost) \
                  url=("https://" . $HEupdatehost . $HEupdatepath . \
                          "?myip=" . $HEipv4addr . \
                          "&password=" . $HEupdatekey . \
                          "&username=" . $HEuserid . \
                          "&hostname=" . $HEtunnelid) \
                  dst-path=($outputfile)

:log info ([/file get ($outputfile) contents])
/file remove ($outputfile)

修改最前面部分的配置,给read、write、policy、test四个权限,然后把script名字填到/ppp profile edit default on-up

重启一下ppp,等待以下log:

Updating IPv6 Tunnel 123456 Client IPv4 address to new IP 1.2.3.4...

然后在TunnelBroker页面上看到Client IPv4 Address一项已被修改,说明script配置成功。

注:如果经常出现对端IP更新不成功导致隧道无法使用的情况,可以适当增大script中的delay后面的数值(一般30左右即可)。

感谢AS394144在本文撰写过程中提供的帮助。

参考:

发表评论

电子邮件地址不会被公开。 必填项已用*标注

此站点使用Akismet来减少垃圾评论。了解我们如何处理您的评论数据