V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
fan88
V2EX  ›  宽带症候群

zt 的 allowGlobal 选项有办法设置为永久或者写在配置文件里面?及其痛苦

  •  
  •   fan88 · 2022-01-25 10:41:15 +08:00 · 1221 次点击
    这是一个创建于 815 天前的主题,其中的信息可能已经有所发展或是发生改变。
    要允许 ZT 接口接受公网路由,必须敲 zerotier-cli set xxxxxxxxxxxx allowGlobal=true

    敲一次也就算了,每次接口断开重连以后都要敲,总有几次忘记的,业务直接断,快他吗痛苦死了。

    可以写在配置文件里面?官网文档好像没有查到。
    6 条回复    2022-01-26 14:21:48 +08:00
    mhycy
        1
    mhycy  
       2022-01-25 10:47:11 +08:00
    /var/lib/zerotier-one/networks.d
    这个目录下的 <networkId>.local.conf 可配置
    fan88
        2
    fan88  
    OP
       2022-01-25 11:14:17 +08:00
    @mhycy 重启网络接口后,这个文件就被清除了。 如果没有手动设置 zerotier-cli set xxxxxxxxxxxx allowGlobal=true 这个文件就不会生成。。。
    mhycy
        3
    mhycy  
       2022-01-25 11:37:35 +08:00
    @fan88 你这是 openwrt 么?
    fan88
        4
    fan88  
    OP
       2022-01-25 12:30:57 +08:00
    @mhycy
    mhycy
        5
    mhycy  
       2022-01-25 13:56:06 +08:00
    @fan88 openwrt 需要修改启动脚本,启动脚本在启动的时候把配置文件清空掉了用 config 内容替换
    具体看看 /etc/init.d/zerotier
    fan88
        6
    fan88  
    OP
       2022-01-26 14:21:48 +08:00
    @mhycy 打开了这个脚本... 完全没看懂 应该改哪里呀


    #!/bin/sh /etc/rc.common

    START=99

    USE_PROCD=1

    PROG=/usr/bin/zerotier-one
    CONFIG_PATH=/var/lib/zerotier-one

    service_triggers() {
    procd_add_reload_trigger "zerotier"
    procd_add_interface_trigger "interface.*.up" wan /etc/init.d/zerotier restart
    }

    section_enabled() {
    config_get_bool enabled "$1" 'enabled' 0
    [ $enabled -gt 0 ]
    }

    start_instance() {
    local cfg="$1"
    local port secret config_path
    local ARGS=""

    if ! section_enabled "$cfg"; then
    echo "disabled in config"
    return 1
    fi

    [ -d /etc/config/zero ] || mkdir -p /etc/config/zero
    config_path=/etc/config/zero

    config_get_bool port $cfg 'port'
    config_get secret $cfg 'secret'

    # Remove existing link or folder
    rm -rf $CONFIG_PATH

    # Create link from CONFIG_PATH to config_path
    if [ -n "$config_path" -a "$config_path" != $CONFIG_PATH ]; then
    if [ ! -d "$config_path" ]; then
    echo "ZeroTier config_path does not exist: $config_path"
    return
    fi

    ln -s $config_path $CONFIG_PATH
    fi

    mkdir -p $CONFIG_PATH/networks.d

    if [ -n "$port" ]; then
    ARGS="$ARGS -p$port"
    fi

    if [ "$secret" = "generate" ]; then
    echo "Generate secret - please wait..."
    local sf="/tmp/zt.$cfg.secret"

    zerotier-idtool generate "$sf" > /dev/null
    [ $? -ne 0 ] && return 1

    secret="$(cat $sf)"
    rm "$sf"

    uci set zerotier.$cfg.secret="$secret"
    uci commit zerotier
    fi

    if [ -n "$secret" ]; then
    echo "$secret" > $CONFIG_PATH/identity.secret
    # make sure there is not previous identity.public
    rm -f $CONFIG_PATH/identity.public
    fi

    add_join() {
    # an (empty) config file will cause ZT to join a network
    touch $CONFIG_PATH/networks.d/$1.conf
    }

    config_list_foreach $cfg 'join' add_join

    procd_open_instance
    procd_set_param command $PROG $ARGS $CONFIG_PATH
    procd_set_param stderr 1
    procd_close_instance
    }

    start_service() {
    config_load 'zerotier'
    config_foreach start_instance 'zerotier'
    touch /tmp/zero.log && /etc/zerotier.start > /tmp/zero.log 2>&1 &
    }

    stop_instance() {
    rm -f /tmp/zero.log
    local cfg="$1"

    /etc/zerotier.stop > /tmp/zero.log 2>&1 &

    # Remove existing link or folder
    rm -f $CONFIG_PATH/networks.d/*.conf
    rm -rf $CONFIG_PATH
    }

    stop_service() {
    config_load 'zerotier'
    config_foreach stop_instance 'zerotier'
    }

    reload_service() {
    stop
    start
    }
    关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   我们的愿景   ·   实用小工具   ·   2741 人在线   最高记录 6543   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 26ms · UTC 14:50 · PVG 22:50 · LAX 07:50 · JFK 10:50
    Developed with CodeLauncher
    ♥ Do have faith in what you're doing.