恩山无线论坛

 找回密码
 立即注册

QQ登录

只需一步,快速开始

搜索
当贝投影
查看: 204|回复: 2

请问Padavan V/P/N/客户端 分流脚本设置

[复制链接]
发表于 2022-6-21 17:21 | 显示全部楼层 |阅读模式
本帖最后由 xui168 于 2022-6-21 17:24 编辑

请问 Padavan V/P/N/客户端 分流脚本怎么设置,我有三台Padavan,打算组网用的,比如增加192.168.8.1,192.168.7.10,脚本要怎么设置啊,本人小白一个,请求各位帮帮我,十分感谢。






#!/bin/sh
source /etc/storage/script/init.sh
### Custom user script
### Called after internal virtual** client connected/disconnected to remote virtual** server
### $1        - action (up/down)
### $IFNAME   - tunnel interface name (e.g. ppp5 or tun0)
### $IPLOCAL  - tunnel local IP address
### $IPREMOTE - tunnel remote IP address
### $DNS1     - peer DNS1
### $DNS2     - peer DNS2
# virtual**国内外自动分流功能 0关闭;1启动
virtual**s=`nvram get virtual**c_fw_enable`

# virtual**线路流向选择 0出国海淘海淘;1回国
virtual**c_fw_rules=`nvram get virtual**c_fw_rules`

#confdir=`grep "/tmp/ss/dnsmasq.d" /etc/storage/dnsmasq/dnsmasq.conf | sed 's/.*\=//g'`
#if [ -z "$confdir" ] ; then
    confdir="/tmp/ss/dnsmasq.d"
#fi
[ ! -d "$confdir" ] && mkdir -p $confdir
restart_dhcpd
# private LAN subnet behind a remote server (example)
peer_lan="192.168.9.0"
peer_msk="255.255.255.0"

### example: add static route to private LAN subnet behind a remote server

func_ipup()
{
#  route add -net $peer_lan netmask $peer_msk gw $IPREMOTE dev $IFNAME
  if [ "$virtual**s" = "1" ] ; then
    [ -f /tmp/virtual**c.lock ] && logger -t "【virtual** 分流】" "等待45秒开始脚本"
    I=45
    while [ -f /tmp/virtual**c.lock ]; do
            I=$(($I - 1))
            [ $I -lt 0 ] && break
            sleep 1
    done
    touch /tmp/virtual**c.lock
    logger -t "【virtual** 分流】" "下载并运行 ip-pre-up 添加规则"
    if [ ! -s "/tmp/ip-pre-up" ] ; then
        wgetcurl.sh /tmp/ip-pre-up "$hiboyfile/ip-pre-up" "$hiboyfile2/ip-pre-up"
    fi
    if [ ! -s "/tmp/ip-pre-up" ] ; then
        wgetcurl.sh /tmp/ip-pre-up "$hiboyfile/ip-pre-up" "$hiboyfile2/ip-pre-up"
    fi
    chmod 777 "/tmp/ip-pre-up"
        if [ "$virtual**c_fw_rules" = "1" ] ; then
            /tmp/ip-pre-up $IPREMOTE
        else
            /tmp/ip-pre-up
        fi
    if [ ! -s "/tmp/ip-down" ] ; then
        wgetcurl.sh /tmp/ip-down "$hiboyfile/ip-down" "$hiboyfile2/ip-down"
      chmod 777 "/tmp/ip-down"
    fi
    if [ ! -s "/tmp/ip-down" ] ; then
        wgetcurl.sh /tmp/ip-down "$hiboyfile/ip-down" "$hiboyfile2/ip-down"
    fi
    rm -f /tmp/virtual**c.lock
    logger -t "【virtual** 分流】" "ip-pre-up 添加规则完成"
  else
    rm -f /tmp/virtual**c.lock
  fi
  return 0
}

func_ipdown()
{
#  route del -net $peer_lan netmask $peer_msk gw $IPREMOTE dev $IFNAME
  if [ "$virtual**s" = "1" ] ; then
    [ -f /tmp/virtual**c.lock ] && logger -t "【virtual** 分流】" "等待45秒开始脚本"
    I=45
    while [ -f /tmp/virtual**c.lock ]; do
            I=$(($I - 1))
            [ $I -lt 0 ] && break
            sleep 1
    done
    touch /tmp/virtual**c.lock
    logger -t "【virtual** 分流】" "下载并运行 ip-down 删除规则"
    if [ ! -s "/tmp/ip-down" ] ; then
        wgetcurl.sh /tmp/ip-down "$hiboyfile/ip-down" "$hiboyfile2/ip-down"
    fi
    if [ ! -s "/tmp/ip-down" ] ; then
        wgetcurl.sh /tmp/ip-down "$hiboyfile/ip-down" "$hiboyfile2/ip-down"
    fi
    chmod 777 "/tmp/ip-down"
    /tmp/ip-down
    #if [ -s "/tmp/ip-pre-up" ] ; then
    #  rm -f /tmp/ip-pre-up
    #  rm -f /tmp/ip-down
    #fi
    rm -f /tmp/virtual**c.lock
    #logger -t "【virtual** 分流】" "ip-down 删除规则完成"
  else
    rm -f /tmp/virtual**c.lock
  fi
  return 0
}

logger -t "【virtual**客户端脚本】" "$IFNAME $1"

case "$1" in
up)
  func_ipup
  ;;
down)
  func_ipdown
  ;;
esac


1.png
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2022-6-23 11:58 来自手机 | 显示全部楼层
大神帮帮我吧
我的恩山、我的无线 The best wifi forum is right here.
 楼主| 发表于 2022-6-23 22:43 | 显示全部楼层
已经解决了,在创建/断开到 virtual** 服务器的连接后运行脚本
  func_ipup后面增加

route del -net 10.0.100.30 netmask 255.255.255.255 gw 10.1.0.1
route add -net 10.0.100.30 netmask 255.255.255.255 gw 10.1.0.1

10.0.100.30是分流地址
10.1.0.1是virtual**服务器的网关
我的恩山、我的无线 The best wifi forum is right here.
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|手机版|小黑屋|Archiver|恩山无线论坛(常州市恩山计算机开发有限公司版权所有) ( 苏ICP备05084872号 )|网站地图

GMT+8, 2022-7-3 14:15

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表