[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"project-6099":3},{"id":4,"name":5,"fullName":6,"owner":7,"repo":5,"description":8,"homepage":9,"htmlUrl":10,"language":11,"languages":10,"totalLinesOfCode":10,"stars":12,"forks":13,"watchers":14,"openIssues":15,"contributorsCount":16,"subscribersCount":16,"size":16,"stars1d":17,"stars7d":18,"stars30d":19,"stars90d":16,"forks30d":16,"starsTrendScore":20,"compositeScore":21,"rankGlobal":10,"rankLanguage":10,"license":22,"archived":23,"fork":23,"defaultBranch":24,"hasWiki":23,"hasPages":23,"topics":25,"createdAt":10,"pushedAt":10,"updatedAt":27,"readmeContent":28,"aiSummary":29,"trendingCount":16,"starSnapshotCount":16,"syncStatus":30,"lastSyncTime":31,"discoverSource":32},6099,"shadowsocks-libev","shadowsocks\u002Fshadowsocks-libev","shadowsocks","Bug-fix-only libev port of shadowsocks. Future development moved to shadowsocks-rust","https:\u002F\u002Fgithub.com\u002Fshadowsocks\u002Fshadowsocks-rust",null,"C",16176,6259,735,122,0,1,5,22,3,76.7,"GNU General Public License v3.0",false,"master",[26,7],"c","2026-06-12 04:00:27","# shadowsocks-libev\n\n[![Build Status](https:\u002F\u002Ftravis-ci.com\u002Fshadowsocks\u002Fshadowsocks-libev.svg?branch=master)](https:\u002F\u002Ftravis-ci.com\u002Fshadowsocks\u002Fshadowsocks-libev) [![Snap Status](https:\u002F\u002Fsnapcraft.io\u002Fshadowsocks-libev\u002Fbadge.svg)](https:\u002F\u002Fsnapcraft.io\u002Fshadowsocks-libev)\n\n## Intro\n\n[Shadowsocks-libev](https:\u002F\u002Fshadowsocks.org) is a lightweight secured SOCKS5\nproxy for embedded devices and low-end boxes.\n\nIt is a port of [Shadowsocks](https:\u002F\u002Fgithub.com\u002Fshadowsocks\u002Fshadowsocks)\ncreated by [@clowwindy](https:\u002F\u002Fgithub.com\u002Fclowwindy), and maintained by\n[@madeye](https:\u002F\u002Fgithub.com\u002Fmadeye) and [@linusyang](https:\u002F\u002Fgithub.com\u002Flinusyang).\n\nCurrent version: 3.3.6 | [Changelog](debian\u002Fchangelog)\n\n## Features\n\nShadowsocks-libev is written in pure C and depends on [libev](http:\u002F\u002Fsoftware.schmorp.de\u002Fpkg\u002Flibev.html). It's designed\nto be a lightweight implementation of shadowsocks protocol, in order to keep the resource usage as low as possible.\n\nFor a full list of feature comparison between different versions of shadowsocks,\nrefer to the [Wiki page](https:\u002F\u002Fgithub.com\u002Fshadowsocks\u002Fshadowsocks\u002Fwiki\u002FFeature-Comparison-across-Different-Versions).\n\n## Quick Start\n\nSnap is the recommended way to install the latest binaries.\n\n### Install snap core\n\nhttps:\u002F\u002Fsnapcraft.io\u002Fcore\n\n### Install from snapcraft.io\n\nStable channel:\n\n```bash\nsudo snap install shadowsocks-libev\n```\n\nEdge channel:\n\n```bash\nsudo snap install shadowsocks-libev --edge\n```\n\n## Installation\n\n### Distribution-specific guide\n\n- [Debian & Ubuntu](#debian--ubuntu)\n    + [Install from repository](#install-from-repository-not-recommended)\n    + [Build deb package from source](#build-deb-package-from-source)\n    + [Configure and start the service](#configure-and-start-the-service)\n- [Fedora & RHEL](#fedora--rhel)\n    + [Build from source with centos](#build-from-source-with-centos)\n- [Archlinux & Manjaro](#archlinux--manjaro)\n- [NixOS](#nixos)\n- [Nix](#nix)\n- [Directly build and install on UNIX-like system](#linux)\n- [FreeBSD](#freebsd)\n    + [Install](#install)\n    + [Configuration](#configuration)\n    + [Run](#run)\n    + [Run as client](#run-as-client)\n- [OpenWRT](#openwrt)\n- [OS X](#os-x)\n- [Windows (MinGW)](#windows-mingw)\n- [Docker](#docker)\n\n* * *\n\n### Build from source (CMake)\n\nshadowsocks-libev uses CMake as its sole build system. Start by pulling submodules:\n\n```bash\ngit submodule update --init --recursive\n```\n\nThen build:\n\n```bash\nmkdir -p build && cd build\ncmake ..\nmake\nsudo make install\n```\n\nTo run unit tests:\n\n```bash\ncd build\nctest --output-on-failure\n```\n\n#### CMake options\n\nFor a complete list of available options, run `cmake -LH` from a build directory.\nCommonly used options:\n\n| Option | Default | Description |\n|---|---|---|\n| `-DWITH_EMBEDDED_SRC=OFF` | `ON` | Use system libcork\u002Flibipset\u002Flibbloom instead of bundled submodules |\n| `-DWITH_DOC_MAN=OFF` | `ON` | Skip man page generation (removes asciidoc\u002Fxmlto dependency) |\n| `-DBUILD_TESTING=OFF` | `ON` | Disable unit tests |\n| `-DENABLE_CONNMARKTOS=ON` | `OFF` | Linux netfilter conntrack QoS support |\n| `-DENABLE_NFTABLES=ON` | `OFF` | nftables firewall integration |\n\nOn macOS, if libraries are installed via Homebrew, specify paths:\n\n```bash\ncmake .. -DCMAKE_PREFIX_PATH=\"\u002Fusr\u002Flocal\u002Fopt\u002Fmbedtls;\u002Fusr\u002Flocal\u002Fopt\u002Flibsodium\"\n```\n\n### Debian & Ubuntu\n\n#### Install from repository (not recommended)\n\nShadowsocks-libev is available in the official repository for following distributions:\n\n* Debian 8 or higher, including oldoldstable (jessie), old stable (stretch), stable (buster), testing (bullseye) and unstable (sid)\n* Ubuntu 16.10 or higher\n\n```bash\nsudo apt update\nsudo apt install shadowsocks-libev\n```\n\n#### Build deb package from source\n\nYou can build shadowsocks-libev and all its dependencies by script:\n\n```bash\nmkdir -p ~\u002Fbuild-area\u002F\ncp .\u002Fscripts\u002Fbuild_deb.sh ~\u002Fbuild-area\u002F\ncd ~\u002Fbuild-area\n.\u002Fbuild_deb.sh\n```\n\nFor older systems, building `.deb` packages is not supported.\nPlease try to build and install directly from source. See the [Linux](#linux) section below.\n\n#### Configure and start the service\n\n```\n# Edit the configuration file\nsudo vim \u002Fetc\u002Fshadowsocks-libev\u002Fconfig.json\n\n# Edit the default configuration for debian\nsudo vim \u002Fetc\u002Fdefault\u002Fshadowsocks-libev\n\n# Start the service\nsudo \u002Fetc\u002Finit.d\u002Fshadowsocks-libev start    # for sysvinit, or\nsudo systemctl start shadowsocks-libev      # for systemd\n```\n\n### Fedora & RHEL\n\nSupported distributions:\n\n* Recent Fedora versions (until EOL)\n* RHEL 6, 7 and derivatives (including CentOS, Scientific Linux)\n\n#### Build from source with centos\n\nIf you are using CentOS 7, you need to install these prerequirements to build from source code:\n\n```bash\nyum install epel-release -y\nyum install gcc gettext autoconf libtool automake make pcre-devel asciidoc xmlto c-ares-devel libev-devel libsodium-devel mbedtls-devel -y\n```\n\n### Archlinux & Manjaro\n\n```bash\nsudo pacman -S shadowsocks-libev\n```\n\nPlease refer to downstream [PKGBUILD](https:\u002F\u002Fgithub.com\u002Farchlinux\u002Fsvntogit-community\u002Fblob\u002Fpackages\u002Fshadowsocks-libev\u002Ftrunk\u002FPKGBUILD)\nscript for extra modifications and distribution-specific bugs.\n\n### NixOS\n\n```bash\nnix-env -iA nixos.shadowsocks-libev\n```\n\n### Nix\n\n```bash\nnix-env -iA nixpkgs.shadowsocks-libev\n```\n\n### Linux\n\nIn general, you need the following build dependencies:\n\n* cmake (>= 3.2)\n* a C compiler (gcc or clang)\n* pkg-config\n* libmbedtls\n* libsodium (>= 1.0.4)\n* libpcre2\n* libev\n* libc-ares\n* asciidoc (for documentation only)\n* xmlto (for documentation only)\n\nIf your system is too old to provide libmbedtls and libsodium (>= 1.0.4), you will need to either install those libraries manually or upgrade your system.\n\nInstall build dependencies for your distribution:\n\n```bash\n# Debian \u002F Ubuntu\nsudo apt-get install --no-install-recommends build-essential cmake pkg-config \\\n    libpcre2-dev libev-dev libc-ares-dev libmbedtls-dev libsodium-dev \\\n    asciidoc xmlto\n\n# CentOS \u002F Fedora \u002F RHEL\nsudo yum install gcc cmake make pkg-config pcre2-devel c-ares-devel \\\n    libev-devel libsodium-devel mbedtls-devel asciidoc xmlto\n\n# Arch\nsudo pacman -S gcc cmake make pkg-config pcre2 c-ares libev libsodium mbedtls \\\n    asciidoc xmlto\n```\n\nThen build and install:\n\n```bash\ngit submodule update --init --recursive\nmkdir -p build && cd build\ncmake ..\nmake\nsudo make install\n```\n\n### FreeBSD\n#### Install\nShadowsocks-libev is available in FreeBSD Ports Collection. You can install it in either way, `pkg` or `ports`.\n\n**pkg (recommended)**\n\n```bash\npkg install shadowsocks-libev\n```\n\n**ports**\n\n```bash\ncd \u002Fusr\u002Fports\u002Fnet\u002Fshadowsocks-libev\nmake install\n```\n\n#### Configuration\nEdit your `config.json` file. By default, it's located in `\u002Fusr\u002Flocal\u002Fetc\u002Fshadowsocks-libev`.\n\nTo enable shadowsocks-libev, add the following rc variable to your `\u002Fetc\u002Frc.conf` file:\n\n```\nshadowsocks_libev_enable=\"YES\"\n```\n\n#### Run\n\nStart the Shadowsocks server:\n\n```bash\nservice shadowsocks_libev start\n```\n\n#### Run as client\nBy default, shadowsocks-libev is running as a server in FreeBSD. If you would like to start shadowsocks-libev in client mode, you can modify the rc script (`\u002Fusr\u002Flocal\u002Fetc\u002Frc.d\u002Fshadowsocks_libev`) manually.\n\n```\n# modify the following line from \"ss-server\" to \"ss-local\"\ncommand=\"\u002Fusr\u002Flocal\u002Fbin\u002Fss-local\"\n```\n\nNote that is simply a workaround, each time you upgrade the port your changes will be overwritten by the new version.\n\n### OpenWRT\n\nThe OpenWRT project is maintained here:\n[openwrt-shadowsocks](https:\u002F\u002Fgithub.com\u002Fshadowsocks\u002Fopenwrt-shadowsocks).\n\n### OS X\nFor OS X, use [Homebrew](http:\u002F\u002Fbrew.sh) to install or build.\n\nInstall Homebrew:\n\n```bash\nruby -e \"$(curl -fsSL https:\u002F\u002Fraw.githubusercontent.com\u002FHomebrew\u002Finstall\u002Fmaster\u002Finstall)\"\n```\nInstall shadowsocks-libev:\n\n```bash\nbrew install shadowsocks-libev\n```\n\n### Windows (MinGW)\nTo build Windows native binaries, the recommended method is to use Docker:\n\n* On Windows: double-click `make.bat` in `docker\\mingw`\n* On Unix-like system:\n\n        cd shadowsocks-libev\u002Fdocker\u002Fmingw\n        make\n\nA tarball with 32-bit and 64-bit binaries will be generated in the same directory.\n\nYou could also manually use MinGW-w64 compilers to build in Unix-like shell (MSYS2\u002FCygwin), or cross-compile on Unix-like systems (Linux\u002FMacOS). Please refer to build scripts in `docker\u002Fmingw`.\n\nCurrently you need to use a patched libev library for MinGW:\n\n* https:\u002F\u002Fgithub.com\u002Fshadowsocks\u002Flibev\u002Farchive\u002Fmingw.zip\n\nNotice that TCP Fast Open (TFO) is only available on **Windows 10**, **1607** or later version (precisely, build >= 14393). If you are using **1709** (build 16299) or later version, you also need to run the following command in PowerShell\u002FCommand Prompt **as Administrator** and **reboot** to use TFO properly:\n\n        netsh int tcp set global fastopenfallback=disabled\n\n### Docker\n\nAs you expect, simply pull the image and run.\n```\ndocker pull shadowsocks\u002Fshadowsocks-libev\ndocker run -e PASSWORD=\u003Cpassword> -p\u003Cserver-port>:8388 -p\u003Cserver-port>:8388\u002Fudp -d shadowsocks\u002Fshadowsocks-libev\n```\n\nMore information about the image can be found [here](docker\u002Falpine\u002FREADME.md).\n\n## Usage\n\nFor a detailed and complete list of all supported arguments,\nyou may refer to the man pages of the applications, respectively.\n\n    ss-[local|redir|server|tunnel|manager]\n\n       -s \u003Cserver_host>           Host name or IP address of your remote server.\n\n       -p \u003Cserver_port>           Port number of your remote server.\n\n       -l \u003Clocal_port>            Port number of your local server.\n\n       -k \u003Cpassword>              Password of your remote server.\n\n       -m \u003Cencrypt_method>        Encrypt method: rc4-md5,\n                                  aes-128-gcm, aes-192-gcm, aes-256-gcm,\n                                  aes-128-cfb, aes-192-cfb, aes-256-cfb,\n                                  aes-128-ctr, aes-192-ctr, aes-256-ctr,\n                                  camellia-128-cfb, camellia-192-cfb,\n                                  camellia-256-cfb, bf-cfb,\n                                  chacha20-ietf-poly1305,\n                                  xchacha20-ietf-poly1305,\n                                  salsa20, chacha20 and chacha20-ietf.\n                                  The default cipher is chacha20-ietf-poly1305.\n\n       [-a \u003Cuser>]                Run as another user.\n\n       [-f \u003Cpid_file>]            The file path to store pid.\n\n       [-t \u003Ctimeout>]             Socket timeout in seconds.\n\n       [-c \u003Cconfig_file>]         The path to config file.\n\n       [-n \u003Cnumber>]              Max number of open files.\n\n       [-i \u003Cinterface>]           Network interface to bind.\n                                  (not available in redir mode)\n\n       [-b \u003Clocal_address>]       Local address to bind.\n                                  For servers: Specify the local address to use \n                                  while this server is making outbound \n                                  connections to remote servers on behalf of the\n                                  clients.\n                                  For clients: Specify the local address to use \n                                  while this client is making outbound \n                                  connections to the server.\n\n       [-u]                       Enable UDP relay.\n                                  (TPROXY is required in redir mode)\n\n       [-U]                       Enable UDP relay and disable TCP relay.\n                                  (not available in local mode)\n\n       [-T]                       Use tproxy instead of redirect. (for tcp)\n                                  (only available in redir mode)\n\n       [-L \u003Caddr>:\u003Cport>]         Destination server address and port\n                                  for local port forwarding.\n                                  (only available in tunnel mode)\n\n       [-6]                       Resolve hostname to IPv6 address first.\n\n       [-d \u003Caddr>]                Name servers for internal DNS resolver.\n                                  (only available in server mode)\n\n       [--reuse-port]             Enable port reuse.\n\n       [--fast-open]              Enable TCP fast open.\n                                  with Linux kernel > 3.7.0.\n                                  (only available in local and server mode)\n\n       [--acl \u003Cacl_file>]         Path to ACL (Access Control List).\n                                  (only available in local and server mode)\n\n       [--manager-address \u003Caddr>] UNIX domain socket address.\n                                  (only available in server and manager mode)\n\n       [--mtu \u003CMTU>]              MTU of your network interface.\n\n       [--mptcp]                  Enable Multipath TCP on MPTCP Kernel.\n\n       [--no-delay]               Enable TCP_NODELAY.\n\n       [--executable \u003Cpath>]      Path to the executable of ss-server.\n                                  (only available in manager mode)\n\n       [-D \u003Cpath>]                Path to the working directory of ss-manager.\n                                  (only available in manager mode)\n\n       [--key \u003Ckey_in_base64>]    Key of your remote server.\n\n       [--plugin \u003Cname>]          Enable SIP003 plugin. (Experimental)\n\n       [--plugin-opts \u003Coptions>]  Set SIP003 plugin options. (Experimental)\n\n       [-v]                       Verbose mode.\n\n## Helper Scripts\n\n### ss-setup\n\n`ss-setup` is an interactive TUI (text user interface) tool for setting up shadowsocks-libev server and client configurations. It uses `whiptail` or `dialog` for the menu interface.\n\nIt is installed automatically by `make install` and can also be run directly from `scripts\u002Fss-setup.sh`.\n\n**Prerequisites:** `whiptail` or `dialog`, `openssl` (optional, for password generation)\n\n#### Server setup (with systemd service)\n\nRun as root for full functionality (config + systemd service installation):\n\n```bash\nsudo ss-setup\n```\n\nThis launches an interactive menu that walks you through:\n1. Choosing a config instance name\n2. Setting the listen address and port (manual or random high port)\n3. Selecting an AEAD cipher (chacha20-ietf-poly1305, aes-256-gcm, etc.)\n4. Generating or entering a password\n5. Configuring timeout, network mode (TCP\u002FUDP), and TCP Fast Open\n6. Optionally selecting a SIP003 plugin\n7. Installing and starting a systemd service\n\nThe config is saved to `\u002Fetc\u002Fshadowsocks-libev\u002F\u003Cname>.json` and a systemd template service `shadowsocks-libev-server@\u003Cname>.service` is created.\n\nAt the end, it displays a `ss:\u002F\u002F` URI you can import into clients.\n\n#### Client config generation\n\nSelect \"Generate ss-local client config\" from the main menu. The wizard prompts for the remote server address, port, cipher, password, and local SOCKS5 port, then writes a JSON config:\n\n```bash\n# Run without root to generate config in the current directory\nss-setup\n# Select: client -> fill in server details -> save\n\n# Then start the client\nss-local -c ~\u002Fss-client.json\n```\n\n#### Config-only mode (non-root)\n\nWhen run without root, `ss-setup` skips service installation and plugin management, but still generates config files in the current directory:\n\n```bash\nss-setup\n# Config saved to .\u002Fconfig.json (in current directory)\n# Start manually:\nss-server -c .\u002Fconfig.json\n```\n\n#### Service management\n\nFrom the main menu, select \"Manage running services\" to start, stop, restart, enable\u002Fdisable, or view logs for any configured instance:\n\n```\nsudo ss-setup\n# Select: service -> pick instance -> start\u002Fstop\u002Frestart\u002Flogs\n```\n\n#### Plugin installation\n\nSelect \"Install a SIP003 plugin\" from the main menu (requires root). Supports automatic download of:\n- simple-obfs (build from source or package manager)\n- v2ray-plugin (GitHub release)\n- xray-plugin (GitHub release)\n- kcptun (GitHub release)\n- Custom plugin binary\n\n### ss-nat\n\n`ss-nat` is a helper script that sets up iptables NAT rules for `ss-redir` to provide transparent TCP\u002FUDP redirection. It is installed on Linux systems by `make install`.\n\n**Prerequisites:** Linux with `iptables`, `ipset`, and optionally TPROXY kernel module for UDP\n\n#### Basic usage (TCP redirect)\n\n```bash\n# Start ss-redir first\nss-redir -s YOUR_SERVER_IP -p 8388 -l 1080 -k PASSWORD -m chacha20-ietf-poly1305 -u\n\n# Set up NAT rules to redirect TCP traffic through ss-redir\nsudo ss-nat -s YOUR_SERVER_IP -l 1080\n```\n\n#### Enable UDP relay with TPROXY\n\n```bash\nsudo ss-nat -s YOUR_SERVER_IP -l 1080 -u\n```\n\n#### Apply rules to OUTPUT chain (proxy the local machine itself)\n\n```bash\nsudo ss-nat -s YOUR_SERVER_IP -l 1080 -u -o\n```\n\n#### Use separate TCP\u002FUDP servers\n\n```bash\nsudo ss-nat -s TCP_SERVER_IP -l 1080 -S UDP_SERVER_IP -L 1080 -U\n```\n\n#### Bypass specific WAN IPs\n\n```bash\nsudo ss-nat -s YOUR_SERVER_IP -l 1080 -b \"1.2.3.4 5.6.7.8\"\n```\n\n#### Use a bypass IP list file\n\n```bash\n# Create a file with one IP\u002FCIDR per line\necho \"1.2.3.0\u002F24\" > \u002Fetc\u002Fss-bypass.list\necho \"5.6.7.0\u002F24\" >> \u002Fetc\u002Fss-bypass.list\n\nsudo ss-nat -s YOUR_SERVER_IP -l 1080 -i \u002Fetc\u002Fss-bypass.list\n```\n\n#### LAN access control\n\n```bash\n# Whitelist mode: only proxy traffic from these LAN IPs\nsudo ss-nat -s YOUR_SERVER_IP -l 1080 -a \"w192.168.1.10 192.168.1.20\"\n\n# Blacklist mode: proxy all LAN traffic except these IPs\nsudo ss-nat -s YOUR_SERVER_IP -l 1080 -a \"b192.168.1.100\"\n```\n\n#### Flush all rules\n\n```bash\nsudo ss-nat -f\n```\n\n#### Complete example: transparent proxy gateway\n\nSet up a Linux box as a transparent proxy gateway for the entire LAN:\n\n```bash\n# 1. Start ss-redir with UDP relay\nss-redir -s YOUR_SERVER_IP -p 8388 -l 1080 -k PASSWORD \\\n    -m chacha20-ietf-poly1305 -u -f \u002Fvar\u002Frun\u002Fss-redir.pid\n\n# 2. Set up NAT rules (TCP + UDP, apply to local OUTPUT too)\nsudo ss-nat -s YOUR_SERVER_IP -l 1080 -u -o -I eth0\n\n# 3. Point other devices' default gateway to this machine's LAN IP\n#    and set their DNS to a public resolver (e.g., 1.1.1.1 or 8.8.8.8)\n\n# To tear down:\nsudo ss-nat -f\n```\n\n## Transparent proxy (manual iptables)\n\nThe latest shadowsocks-libev has provided a *redir* mode. You can configure your Linux-based box or router to proxy all TCP traffic transparently, which is handy if you use an OpenWRT-powered router.\n\nNote: For most use cases, [`ss-nat`](#ss-nat) above is simpler than writing iptables rules manually.\n\n    # Create new chain\n    iptables -t nat -N SHADOWSOCKS\n    iptables -t mangle -N SHADOWSOCKS\n\n    # Ignore your shadowsocks server's addresses\n    # It's very IMPORTANT, just be careful.\n    iptables -t nat -A SHADOWSOCKS -d 123.123.123.123 -j RETURN\n\n    # Ignore LANs and any other addresses you'd like to bypass the proxy\n    # See Wikipedia and RFC5735 for full list of reserved networks.\n    # See ashi009\u002Fbestroutetb for a highly optimized CHN route list.\n    iptables -t nat -A SHADOWSOCKS -d 0.0.0.0\u002F8 -j RETURN\n    iptables -t nat -A SHADOWSOCKS -d 10.0.0.0\u002F8 -j RETURN\n    iptables -t nat -A SHADOWSOCKS -d 127.0.0.0\u002F8 -j RETURN\n    iptables -t nat -A SHADOWSOCKS -d 169.254.0.0\u002F16 -j RETURN\n    iptables -t nat -A SHADOWSOCKS -d 172.16.0.0\u002F12 -j RETURN\n    iptables -t nat -A SHADOWSOCKS -d 192.168.0.0\u002F16 -j RETURN\n    iptables -t nat -A SHADOWSOCKS -d 224.0.0.0\u002F4 -j RETURN\n    iptables -t nat -A SHADOWSOCKS -d 240.0.0.0\u002F4 -j RETURN\n\n    # Anything else should be redirected to shadowsocks's local port\n    iptables -t nat -A SHADOWSOCKS -p tcp -j REDIRECT --to-ports 12345\n\n    # Add any UDP rules\n    ip route add local default dev lo table 100\n    ip rule add fwmark 1 lookup 100\n    iptables -t mangle -A SHADOWSOCKS -p udp --dport 53 -j TPROXY --on-port 12345 --tproxy-mark 0x01\u002F0x01\n\n    # Apply the rules\n    iptables -t nat -A PREROUTING -p tcp -j SHADOWSOCKS\n    iptables -t mangle -A PREROUTING -j SHADOWSOCKS\n\n    # Start the shadowsocks-redir\n    ss-redir -u -c \u002Fetc\u002Fconfig\u002Fshadowsocks.json -f \u002Fvar\u002Frun\u002Fshadowsocks.pid\n\n## Transparent proxy (pure tproxy)\n\nExecuting this script on the linux host can proxy all outgoing traffic of this machine (except the traffic sent to the reserved address). Other hosts under the same LAN can also change their default gateway to the ip of this linux host (at the same time change the dns server to 1.1.1.1 or 8.8.8.8, etc.) to proxy their outgoing traffic.\n\n> Of course, the ipv6 proxy is similar, just change `iptables` to `ip6tables`, `ip` to `ip -6`, `127.0.0.1` to `::1`, and other details.\n\n```shell\n#!\u002Fbin\u002Fbash\n\nstart_ssredir() {\n    # please modify MyIP, MyPort, etc.\n    (ss-redir -s MyIP -p MyPort -m MyMethod -k MyPasswd -b 127.0.0.1 -l 60080 --no-delay -u -T -v \u003C\u002Fdev\u002Fnull &>>\u002Fvar\u002Flog\u002Fss-redir.log &)\n}\n\nstop_ssredir() {\n    kill -9 $(pidof ss-redir) &>\u002Fdev\u002Fnull\n}\n\nstart_iptables() {\n    ##################### SSREDIR #####################\n    iptables -t mangle -N SSREDIR\n\n    # connection-mark -> packet-mark\n    iptables -t mangle -A SSREDIR -j CONNMARK --restore-mark\n    iptables -t mangle -A SSREDIR -m mark --mark 0x2333 -j RETURN\n\n    # please modify MyIP, MyPort, etc.\n    # ignore traffic sent to ss-server\n    iptables -t mangle -A SSREDIR -p tcp -d MyIP --dport MyPort -j RETURN\n    iptables -t mangle -A SSREDIR -p udp -d MyIP --dport MyPort -j RETURN\n\n    # ignore traffic sent to reserved addresses\n    iptables -t mangle -A SSREDIR -d 0.0.0.0\u002F8          -j RETURN\n    iptables -t mangle -A SSREDIR -d 10.0.0.0\u002F8         -j RETURN\n    iptables -t mangle -A SSREDIR -d 100.64.0.0\u002F10      -j RETURN\n    iptables -t mangle -A SSREDIR -d 127.0.0.0\u002F8        -j RETURN\n    iptables -t mangle -A SSREDIR -d 169.254.0.0\u002F16     -j RETURN\n    iptables -t mangle -A SSREDIR -d 172.16.0.0\u002F12      -j RETURN\n    iptables -t mangle -A SSREDIR -d 192.0.0.0\u002F24       -j RETURN\n    iptables -t mangle -A SSREDIR -d 192.0.2.0\u002F24       -j RETURN\n    iptables -t mangle -A SSREDIR -d 192.88.99.0\u002F24     -j RETURN\n    iptables -t mangle -A SSREDIR -d 192.168.0.0\u002F16     -j RETURN\n    iptables -t mangle -A SSREDIR -d 198.18.0.0\u002F15      -j RETURN\n    iptables -t mangle -A SSREDIR -d 198.51.100.0\u002F24    -j RETURN\n    iptables -t mangle -A SSREDIR -d 203.0.113.0\u002F24     -j RETURN\n    iptables -t mangle -A SSREDIR -d 224.0.0.0\u002F4        -j RETURN\n    iptables -t mangle -A SSREDIR -d 240.0.0.0\u002F4        -j RETURN\n    iptables -t mangle -A SSREDIR -d 255.255.255.255\u002F32 -j RETURN\n\n    # mark the first packet of the connection\n    iptables -t mangle -A SSREDIR -p tcp --syn                      -j MARK --set-mark 0x2333\n    iptables -t mangle -A SSREDIR -p udp -m conntrack --ctstate NEW -j MARK --set-mark 0x2333\n\n    # packet-mark -> connection-mark\n    iptables -t mangle -A SSREDIR -j CONNMARK --save-mark\n\n    ##################### OUTPUT #####################\n    # proxy the outgoing traffic from this machine\n    iptables -t mangle -A OUTPUT -p tcp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j SSREDIR\n    iptables -t mangle -A OUTPUT -p udp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j SSREDIR\n\n    ##################### PREROUTING #####################\n    # proxy traffic passing through this machine (other->other)\n    iptables -t mangle -A PREROUTING -p tcp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j SSREDIR\n    iptables -t mangle -A PREROUTING -p udp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j SSREDIR\n\n    # hand over the marked package to TPROXY for processing\n    iptables -t mangle -A PREROUTING -p tcp -m mark --mark 0x2333 -j TPROXY --on-ip 127.0.0.1 --on-port 60080\n    iptables -t mangle -A PREROUTING -p udp -m mark --mark 0x2333 -j TPROXY --on-ip 127.0.0.1 --on-port 60080\n}\n\nstop_iptables() {\n    ##################### PREROUTING #####################\n    iptables -t mangle -D PREROUTING -p tcp -m mark --mark 0x2333 -j TPROXY --on-ip 127.0.0.1 --on-port 60080 &>\u002Fdev\u002Fnull\n    iptables -t mangle -D PREROUTING -p udp -m mark --mark 0x2333 -j TPROXY --on-ip 127.0.0.1 --on-port 60080 &>\u002Fdev\u002Fnull\n\n    iptables -t mangle -D PREROUTING -p tcp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j SSREDIR &>\u002Fdev\u002Fnull\n    iptables -t mangle -D PREROUTING -p udp -m addrtype ! --src-type LOCAL ! --dst-type LOCAL -j SSREDIR &>\u002Fdev\u002Fnull\n\n    ##################### OUTPUT #####################\n    iptables -t mangle -D OUTPUT -p tcp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j SSREDIR &>\u002Fdev\u002Fnull\n    iptables -t mangle -D OUTPUT -p udp -m addrtype --src-type LOCAL ! --dst-type LOCAL -j SSREDIR &>\u002Fdev\u002Fnull\n\n    ##################### SSREDIR #####################\n    iptables -t mangle -F SSREDIR &>\u002Fdev\u002Fnull\n    iptables -t mangle -X SSREDIR &>\u002Fdev\u002Fnull\n}\n\nstart_iproute2() {\n    ip route add local default dev lo table 100\n    ip rule  add fwmark 0x2333        table 100\n}\n\nstop_iproute2() {\n    ip rule  del   table 100 &>\u002Fdev\u002Fnull\n    ip route flush table 100 &>\u002Fdev\u002Fnull\n}\n\nstart_resolvconf() {\n    # or nameserver 8.8.8.8, etc.\n    echo \"nameserver 1.1.1.1\" >\u002Fetc\u002Fresolv.conf\n}\n\nstop_resolvconf() {\n    echo \"nameserver 114.114.114.114\" >\u002Fetc\u002Fresolv.conf\n}\n\nstart() {\n    echo \"start ...\"\n    start_ssredir\n    start_iptables\n    start_iproute2\n    start_resolvconf\n    echo \"start end\"\n}\n\nstop() {\n    echo \"stop ...\"\n    stop_resolvconf\n    stop_iproute2\n    stop_iptables\n    stop_ssredir\n    echo \"stop end\"\n}\n\nrestart() {\n    stop\n    sleep 1\n    start\n}\n\nmain() {\n    if [ $# -eq 0 ]; then\n        echo \"usage: $0 start|stop|restart ...\"\n        return 1\n    fi\n\n    for funcname in \"$@\"; do\n        if [ \"$(type -t $funcname)\" != 'function' ]; then\n            echo \"'$funcname' not a shell function\"\n            return 1\n        fi\n    done\n\n    for funcname in \"$@\"; do\n        $funcname\n    done\n    return 0\n}\nmain \"$@\"\n```\n\n## Security Tips\n\nFor any public server, to avoid users accessing localhost of your server, please add `--acl acl\u002Fserver_block_local.acl` to the command line.\n\nAlthough shadowsocks-libev can handle thousands of concurrent connections nicely, we still recommend\nsetting up your server's firewall rules to limit connections from each user:\n\n    # Up to 32 connections are enough for normal usage\n    iptables -A INPUT -p tcp --syn --dport ${SHADOWSOCKS_PORT} -m connlimit --connlimit-above 32 -j REJECT --reject-with tcp-reset\n\n## License\n\n```\nCopyright: 2013-2015, Clow Windy \u003Cclowwindy42@gmail.com>\n           2013-2018, Max Lv \u003Cmax.c.lv@gmail.com>\n           2014, Linus Yang \u003Clinusyang@gmail.com>\n\nThis program is free software: you can redistribute it and\u002For modify\nit under the terms of the GNU General Public License as published by\nthe Free Software Foundation, either version 3 of the License, or\n(at your option) any later version.\n\nThis program is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\nGNU General Public License for more details.\n\nYou should have received a copy of the GNU General Public License\nalong with this program. If not, see \u003Chttp:\u002F\u002Fwww.gnu.org\u002Flicenses\u002F>.\n```\n","shadowsocks-libev 是一个轻量级的安全 SOCKS5 代理，专为嵌入式设备和低端硬件设计。该项目用纯 C 语言编写，并依赖于 libev 库，旨在尽可能减少资源消耗。它支持多种加密方法，适用于需要低资源占用的场景，如路由器、树莓派等。此外，shadowsocks-libev 提供了跨平台的安装方式，包括通过 snap 包管理器进行快速安装以及从源码编译等多种部署选项，确保用户可以根据自己的需求灵活选择。",2,"2026-06-11 03:05:40","top_language"]