本文最后更新于:2019年3月22日 上午

引言

Linux下搭建socks透明代理,通常都是使用dante。不过鉴于我们还有其他需求(跳墙中转),所以我们选择了使用最近比较热门的v2ray程序。

{
  "log" : {
    "access": "/var/log/v2ray/access.log",
    "error": "/var/log/v2ray/error.log",
    "loglevel": "warning"
  },
  "inbound": {
    "port": 8866,
    "listen": "0.0.0.0",
    "protocol": "socks",
    "settings": {
      "auth": "password",
      "accounts": [
        {
          "user": "my-socks",
          "pass": "my-password"
        }
      ],
      "udp": true,
      "ip": "腾讯云内网IP地址"
    },
    "tag": "socks-in"
  },
  "outbound": {
    "protocol": "shadowsocks",
    "settings": {
      "servers": [
        {
          "email": "ss2@v2ray.com",
          "address": "225.255.255.255",
          "port": 6656,
          "method": "aes-256-cfb",
          "password": "my-password",
          "ota": false
        }
      ]
    },
    "tag": "ss-out"
  },
  "inboundDetour": [
    {
      "port": 8800,
      "listen": "0.0.0.0",
      "protocol": "vmess",
      "settings": {
        "clients": [
          {
            "id": "4119f123-3863-4d3e-aaf6-379fdda3a371",
            "level": 1,
            "alterId": 64,
            "email": "vmess@v2ray.com"
          }
        ]
      },
      "tag": "v2ray-in"
    },
    {
      "port": 8899,
      "listen": "0.0.0.0",
      "protocol": "shadowsocks",
      "settings": {
        "email": "ss1@v2ray.com",
        "method": "aes-256-cfb",
        "password": "my-password",
        "udp": true,
        "level": 0,
        "ota": false
      },
      "tag": "ss-in"
    }
  ],
  "outboundDetour": [
    {
      "protocol": "freedom",
      "settings": {},
      "tag": "direct"
    },
    {
      "protocol": "blackhole",
      "settings": {},
      "tag": "blocked"
    },
    {
      "protocol": "vmess",
      "settings": {
        "vnext": [
          {
            "address": "v2ray.cool",
            "port": 10086,
            "users": [
              {
                "id": "a3482e88-686a-4a58-8126-99c9df64b7bf",
                "alterId": 64,
                "security": "auto"
              }
            ]
          }
        ]
      },
      "mux": {
        "enabled": true
      },
      "tag": "v2ray-out"
    }
  ],
  "dns": {
    "servers": [
      "114.114.114.114",
      "114.114.115.115",
      "localhost"
    ]
  },
  "routing": {
    "strategy": "rules",
    "settings": {
      "domainStrategy": "IPIfNonMatch",
      "rules": [
        {
          "type": "field",
          "ip": [
            "0.0.0.0/8",
            "10.0.0.0/8",
            "100.64.0.0/10",
            "127.0.0.0/8",
            "169.254.0.0/16",
            "172.16.0.0/12",
            "192.0.0.0/24",
            "192.0.2.0/24",
            "192.168.0.0/16",
            "198.18.0.0/15",
            "198.51.100.0/24",
            "203.0.113.0/24",
            "::1/128",
            "fc00::/7",
            "fe80::/10"
          ],
          "outboundTag": "blocked"
        },
        {
          "type": "field",
          "inboundTag": [
            "ss-in"
          ],
          "outboundTag": "ss-out"
        },
        {
          "type": "field",
          "domain": [
            "baidu.com",
            "qq.com"
          ],
          "outboundTag": "direct"
        },
        {
          "type": "chinaip",
          "outboundTag": "direct"
        },
        {
          "type": "chinasites",
          "outboundTag": "direct"
        }
      ]
    }
  }
}

后记