### Start Zapret dvtws Daemon Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Example command to start the dvtws daemon with specific port and DPI desynchronization settings. Ensure any previous instances are killed first. ```bash pkill ^dvtws$ /opt/zapret/nfq/dvtws --port=989 --daemon --dpi-desync=multisplit --dpi-desync-split-pos=2 ``` -------------------------------- ### Run Cygwin Setup with Specific Options Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_windows.txt Execute the Cygwin installer with specific command-line arguments to allow unsupported Windows versions and skip verification. Ensure you install 'make', 'gcc-core', and 'zlib-devel' packages. ```bash setup-x86_64.exe --allow-unsupported-windows --no-verify --site http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2024/01/30/231215 ``` -------------------------------- ### Start Zapret with TPWS and Firewall Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Starts both the TPWS service and the firewall component. Ensure INIT_APPLY_FW is set to 1 in the configuration. ```bash /opt/zapret/init.d/macos/zapret start ``` -------------------------------- ### Easy Zapret Installation Script Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Installs Zapret on most modern Linux distributions, OpenWRT, and MacOS. This script automates the setup process. ```bash install_easy.sh ``` -------------------------------- ### Install Dependencies and Build on Debian/Ubuntu Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_unix.txt Installs necessary development packages and builds Zapret with systemd support on Debian-based systems. ```bash apt install make gcc zlib1g-dev libcap-dev libnetfilter-queue-dev libmnl-dev libsystemd-dev make -C /opt/zapret systemd ``` -------------------------------- ### Download Cygwin Installer Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_windows.txt Use curl to download the Cygwin installer for Windows x64. This is the first step in setting up the necessary environment. ```bash curl -O https://www.cygwin.com/setup-x86_64.exe ``` -------------------------------- ### Start Zapret Daemons Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Use this command to start the Zapret background services. This is useful when managing daemons separately from firewall rules. ```bash /opt/zapret/init.d/sysv/zapret start_daemons ``` -------------------------------- ### Initialize ipfw Firewall Rules Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Use this command in `/etc/rc.firewall.my` to flush existing ipfw rules and start with a clean slate on boot. ```bash ipfw -q -f flush ``` -------------------------------- ### Install Build Packages (Fedora) Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Installs essential build tools and libraries for Fedora-based systems. ```bash dnf install make patch gcc g++ ncurses-devel git perl ``` -------------------------------- ### Install Build Packages (Debian/Ubuntu) Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Installs essential build tools and libraries for Debian-based systems. ```bash apt install build-essential patch libncurses-dev python3-distutils unzip gawk wget git ``` -------------------------------- ### Start tpws with PF and Link-Local Bindings Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Command to start the tpws daemon with PF support enabled, binding to localhost for IPv4 and a specified interface for IPv6 link-local address. ```bash /opt/zapret/tpws/tpws --port=988 --enable-pf --bind-addr=127.0.0.1 --bind-iface6=em1 --bind-linklocal=force ``` -------------------------------- ### NFTABLES Table and Chain Setup Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Creates an 'inet' table named 'ztest' and a 'postrouting' chain with 'mangle' type in the 'postrouting' hook. This is the initial setup for NFTABLES rules. ```bash IFACE_WAN=wan ft create table inet ztest ft add chain inet ztest post "{type filter hook postrouting priority mangle;}" ``` -------------------------------- ### Example: Discord Media and STUN Filtering Source: https://github.com/bol-van/zapret/blob/master/init.d/windivert.filter.examples/README.txt This example demonstrates how to use multiple raw part filters to block media streams in Discord and filter STUN traffic. It also includes L7 filtering and DPI desynchronization. ```bash winws --wf-raw-part=@windivert_part.discord_media.txt --wf-raw-part=@windivert_part.stun.txt --filter-l7=stun,discord --dpi-desync=fake ``` -------------------------------- ### Example nfqws profile creation Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Demonstrates the creation of new desync profiles in nfqws using the --new parameter. The first profile is created automatically. ```bash --new ``` -------------------------------- ### Start Zapret PF Firewall Only Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Starts only the PF firewall component, without affecting TPWS. ```bash /opt/zapret/init.d/macos/zapret start-fw ``` -------------------------------- ### Install WSL Source: https://github.com/bol-van/zapret/blob/master/docs/windows.en.md Command to enable the Windows Subsystem for Linux feature on Windows. ```bash dism.exe /online /enable-feature /featurename:Microsoft-Windows-Subsystem-Linux /all ``` -------------------------------- ### Start Zapret Firewall Rules Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Use this command to apply iptables rules for Zapret. This is useful when managing firewall rules separately from Zapret daemons. ```bash /opt/zapret/init.d/sysv/zapret start_fw ``` -------------------------------- ### Update and Install Feeds and Libraries Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Updates the package feeds and installs necessary libraries for your OpenWrt build environment. ```bash ./scripts/feeds update base packages ./scripts/feeds install libnetfilter-queue zlib libcap ``` -------------------------------- ### Start Zapret TPWS Daemons Only Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Starts only the TPWS daemons, without affecting the firewall. ```bash /opt/zapret/init.d/macos/zapret start-daemons ``` -------------------------------- ### Example of Custom TLS Fakes and Modifications Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Demonstrates how to specify custom TLS fake data and apply different modification strategies for each. ```bash --dpi-desync-fake-tls=iana_org.bin --dpi-desync-fake-tls-mod=rndsni --dpi-desync-fake-tls=0xaabbccdd --dpi-desync-fake-tls-mod=none ``` -------------------------------- ### Configure Zapret Autostart Script for pfSense Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md This script loads ipfw and ipdivert kernel modules, sets firewall redirection rules for HTTP/HTTPS traffic, and starts the dvtws daemon. It includes configurations for both older and newer pfSense versions regarding sysctl parameters and pfctl commands. ```sh #!/bin/sh kldload ipfw kldload ipdivert # for older pfsense versions. newer do not have these sysctls sysctl net.inet.ip.pfil.outbound=ipfw,pf sysctl net.inet.ip.pfil.inbound=ipfw,pf sysctl net.inet6.ip6.pfil.outbound=ipfw,pf sysctl net.inet6.ip6.pfil.inbound=ipfw,pf ipfw delete 100 ipfw add 100 divert 989 tcp from any to any 80,443 out not diverted not sockarg xmit em0 pkill ^dvtws$ dvtws --daemon --port 989 --dpi-desync=multisplit --dpi-desync-split-pos=2 # required for newer pfsense versions (2.6.0 tested) to return ipfw to functional state pfctl -d ; pfctl -e ``` -------------------------------- ### IPFW NAT Setup Source: https://github.com/bol-van/zapret/blob/master/docs/bsdfw.txt A sample IPFW NAT configuration for basic network address translation. This setup involves flushing existing rules, configuring NAT, and defining traffic flow. ```bash WAN=em0 LAN=em1 ipfw -q flush ipfw -q nat 1 config if $WAN unreg_only reset ipfw -q add 10 allow ip from any to any via $LAN ipfw -q add 20 allow ip from any to any via lo0 ipfw -q add 300 nat 1 ip4 from any to any in recv $WAN ipfw -q add 301 check-state ipfw -q add 350 skipto 390 tcp from any to any out xmit $WAN setup keep-state ipfw -q add 350 skipto 390 udp from any to any out xmit $WAN keep-state ipfw -q add 360 allow all from any to me in recv $WAN ipfw -q add 390 nat 1 ip4 from any to any out xmit $WAN ipfw -q add 10000 allow ip from any to any ``` -------------------------------- ### pfSense Autostart Script for Network Services Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.md A sample rc.d script for pfSense to load ipfw and ipdivert kernel modules, configure firewall rules, and start the dvtws daemon. It includes settings for older and newer pfSense versions. ```sh #!/bin/sh kldload ipfw kldload ipdivert # for older pfsense versions. newer do not have these sysctls sysctl net.inet.ip.pfil.outbound=ipfw,pf sysctl net.inet.ip.pfil.inbound=ipfw,pf sysctl net.inet6.ip6.pfil.outbound=ipfw,pf sysctl net.inet6.ip6.pfil.inbound=ipfw,pf ipfw delete 100 ipfw add 100 divert 989 tcp from any to any 80,443 out not diverted xmit em0 pkill ^dvtws$ dvtws --daemon --port 989 --dpi-desync=multisplit --dpi-desync-split-pos=2 # required for newer pfsense versions (2.6.0 tested) to return ipfw to functional state pfctl -d ; pfctl -e ``` -------------------------------- ### Install TPWS on OpenWrt with NFTABLES Source: https://github.com/bol-van/zapret/blob/master/init.d/openwrt-minimal/readme.txt Follow these steps to install the TPWS script on OpenWrt systems using NFTABLES. Ensure the TPWS binary has execute permissions and configure the firewall rules if IPv6 is not desired. ```bash chmod 755 /etc/init.d/tpws /usr/bin/tpws fw4 restart ``` ```bash /etc/init.d/tpws enable /etc/init.d/tpws start ``` -------------------------------- ### Compile Zapret for Cygwin64 Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_windows.txt Compile the Zapret project using the 'make' command with the 'cygwin64' target. This step requires the previously installed 'make' and 'gcc-core' packages. ```bash make cygwin64 ``` -------------------------------- ### Start tpws with PF Support on FreeBSD Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.md Command to launch the tpws daemon with PF enabled, specifying ports, bind address, and interface for IPv6 link-local traffic. ```sh $ /opt/zapret/tpws/tpws --port=988 --enable-pf --bind-addr=127.0.0.1 --bind-iface6=em1 --bind-linklocal=force ``` -------------------------------- ### TPWS Server with PF Integration Source: https://github.com/bol-van/zapret/blob/master/docs/bsdfw.txt Command to start the TPWS server, enabling PF integration. This allows TPWS to interact with PF rules for traffic management. ```bash /opt/zapret/tpws/tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1 --enable-pf ``` -------------------------------- ### Autostart Script for TPWS with pfctl Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md This script loads the Zapret anchor using `pfctl`, kills any running `tpws` processes, and then starts `tpws` as a daemon. It configures `tpws` to listen on a specific port and interface, enabling pf redirection. ```sh pfctl -a zapret -f /etc/zapret.anchor pkill ^tpws$ tpws --daemon --port=988 --enable-pf --bind-addr=127.0.0.1 --bind-iface6=em1 --bind-linklocal=force --split-pos=2 ``` -------------------------------- ### Cygwin Installer for Windows 7 Compatibility Source: https://github.com/bol-van/zapret/blob/master/docs/windows.en.md This command downloads the Cygwin installer and uses specific flags to ensure compatibility with older Windows versions like Windows 7. It's necessary for running Winws and related scripts if you are on an older system. ```bash curl -O https://www.cygwin.com/setup-x86_64.exe setup-x86_64.exe --allow-unsupported-windows --no-verify --site http://ctm.crouchingtigerhiddenfruitbat.org/pub/cygwin/circa/64bit/2024/01/30/231215 ``` -------------------------------- ### TPWS Server Configuration Source: https://github.com/bol-van/zapret/blob/master/docs/bsdfw.txt Command to start the TPWS server, specifying the port, user, and bind addresses. This is often used in conjunction with firewall redirection rules. ```bash /opt/zapret/tpws/tpws --port=988 --user=daemon --bind-addr=::1 --bind-addr=127.0.0.1 ``` -------------------------------- ### Compiling Winws from Source with Cygwin Source: https://github.com/bol-van/zapret/blob/master/docs/windows.en.md Instructions for compiling Winws from source using Cygwin. Ensure you have the necessary development packages installed, such as gcc-core, make, and zlib-devel. The 'make cygwin64' or 'make cygwin32' command is used depending on your system architecture. ```bash make cygwin64 ``` ```bash make cygwin32 ``` -------------------------------- ### OpenBSD pf.conf for dvtws (Zapret Tables) Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Configure pf.conf with zapret tables for IPv4 and IPv6, including exclude lists. This setup redirects specific traffic matching zapret tables to port 989. ```shell set limit table-entries 2000000 table file "/opt/zapret/ipset/zapret-ip.txt" table file "/opt/zapret/ipset/zapret-ip-user.txt" table file "/opt/zapret/ipset/zapret-ip-exclude.txt" pass out quick on em0 inet proto tcp to port {80,443} pass in quick on em0 inet proto tcp from port {80,443} flags SA/SA divert-packet port 989 no state pass in quick on em0 inet proto tcp from port {80,443} no state pass out quick on em0 inet proto tcp to port {80,443} divert-packet port 989 no state pass in quick on em0 inet proto tcp from port {80,443} flags SA/SA divert-packet port 989 no state pass in quick on em0 inet proto tcp from port {80,443} no state pass out quick on em0 inet proto tcp to port {80,443} divert-packet port 989 no state table file "/opt/zapret/ipset/zapret-ip6.txt" table file "/opt/zapret/ipset/zapret-ip-user6.txt" table file "/opt/zapret/ipset/zapret-ip-exclude6.txt" pass out quick on em0 inet6 proto tcp to port {80,443} pass in quick on em0 inet6 proto tcp from port {80,443} flags SA/SA divert-packet port 989 no state pass in quick on em0 inet6 proto tcp from port {80,443} no state pass out quick on em0 inet6 proto tcp to port {80,443} divert-packet port 989 no state pass in quick on em0 inet6 proto tcp from port {80,443} flags SA/SA divert-packet port 989 no state pass in quick on em0 inet6 proto tcp from port {80,443} no state pass out quick on em0 inet6 proto tcp to port {80,443} divert-packet port 989 no state ``` -------------------------------- ### Install Wireless Networking Feature on Windows Server Source: https://github.com/bol-van/zapret/blob/master/docs/windows.en.md Installs the 'Wireless-Networking' Windows feature using PowerShell, which is required for winws on Windows Server. A reboot is necessary after installation. ```powershell Install-WindowsFeature -Name Wireless-Networking ``` -------------------------------- ### Build on FreeBSD Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_unix.txt Builds Zapret on FreeBSD systems. ```bash make -C /opt/zapret ``` -------------------------------- ### Install TPWS on OpenWrt with IPTABLES Source: https://github.com/bol-van/zapret/blob/master/init.d/openwrt-minimal/readme.txt Instructions for installing the TPWS script on OpenWrt systems using IPTABLES. This process involves package installation, file copying, permission setting, and firewall configuration. IPv6 can be disabled by editing the firewall user file. ```bash opkg update opkg install iptables-mod-extra IPV6 ONLY : opkg install ip6tables-mod-nat ``` ```bash chmod 755 /etc/init.d/tpws /usr/bin/tpws fw3 restart ``` ```bash /etc/init.d/tpws enable /etc/init.d/tpws start ``` -------------------------------- ### Download and Extract OpenWrt SDK (xz) Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Downloads the OpenWrt SDK for a specific release and architecture, then extracts it. Ensure you are in the correct directory after extraction. ```bash curl -o - https://downloads.openwrt.org/releases/23.05.5/targets/x86/64/openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64.tar.xz | tar -Jxv cd openwrt-sdk-23.05.5-x86-64_gcc-12.3.0_musl.Linux-x86_64 ``` -------------------------------- ### Build on OpenBSD Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_unix.txt Builds Zapret for OpenBSD systems. ```bash make -C /opt/zapret bsd ``` -------------------------------- ### Enable Firewall and Set Script in FreeBSD Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Enable the firewall service and specify the custom firewall script in `/etc/rc.conf`. This script will be executed on boot. ```bash firewall_enable="YES" firewall_script="/etc/rc.firewall.my" ``` -------------------------------- ### Build on MacOS Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_unix.txt Builds Zapret for MacOS systems. ```bash make -C /opt/zapret mac ``` -------------------------------- ### Navigate to Zapret NFQ Directory Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_windows.txt Change the current directory to the 'nfq' folder within your Zapret installation. This is where the compilation commands will be executed. ```bash cd C:/Users/user/Downloads/zapret/nfq ``` -------------------------------- ### Binding to a Specific Link Local IPv6 Address Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Example of binding to a specific link-local IPv6 address, including the interface name. ```bash --bind-iface6=fe80::aaaa:bbbb:cccc:dddd%iface-name ``` -------------------------------- ### Copy and Prepare Package Definitions Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Copies custom package definitions into the OpenWrt build system and removes redundant subdirectories. ```bash cp -R /opt/zapret/docs/compile/openwrt/. . cp -R /opt/zapret/tpws package/zapret/tpws cp -R /opt/zapret/nfq package/zapret/nfqws cp -R /opt/zapret/mdig package/zapret/mdig cp -R /opt/zapret/ip2net package/zapret/ip2net rm -f package/zapret/tpws/tpws/tpws package/zapret/nfqws/nfq/nfqws package/zapret/mdig/mdig/mdig package/zapret/ip2net/ip2net/ip2net ``` -------------------------------- ### DVTWS Server with DPI Desync Source: https://github.com/bol-van/zapret/blob/master/docs/bsdfw.txt Command to start the DVTWS server with specific DPI desynchronization settings. This is used with PF divert packet rules. ```bash ./dvtws --port=989 --dpi-desync=multisplit --dpi-desync-split-pos=2 ``` -------------------------------- ### Compile Zapret Sources on FreeBSD Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Use this command to compile the Zapret sources on FreeBSD. Ensure you are in the project's root directory. ```bash make ``` -------------------------------- ### NFQWS Packet Counts for Limited Interception Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Specifies the number of starting packets to intercept for NFQWS in both directions (TCP and UDP). It includes a calculation based on AUTOHOSTLIST_RETRANS_THRESHOLD. ```shell NFQWS_TCP_PKT_OUT=$((6+$AUTOHOSTLIST_RETRANS_THRESHOLD)) NFQWS_TCP_PKT_IN=3 NFQWS_UDP_PKT_OUT=$((6+$AUTOHOSTLIST_RETRANS_THRESHOLD)) NFQWS_UDP_PKT_IN=0 ``` -------------------------------- ### Download and Extract OpenWrt SDK (zst) Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Downloads the OpenWrt SDK for a specific snapshot release and architecture using zstd compression, then extracts it. Ensure you are in the correct directory after extraction. ```bash curl -o - https://downloads.openwrt.org/snapshots/targets/x86/64/openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64.tar.zst | tar --zstd -xv cd openwrt-sdk-x86-64_gcc-13.3.0_musl.Linux-x86_64 ``` -------------------------------- ### DVTWS Server Configuration Source: https://github.com/bol-van/zapret/blob/master/docs/bsdfw.txt Command to start the DVTWS server, specifying the port, debug mode, and DPI desynchronization settings. This is used with IPFW divert rules. ```bash /opt/zapret/nfq/dvtws --port=989 --debug --dpi-desync=split ``` -------------------------------- ### Load ipdivert Kernel Module on FreeBSD Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Add `ipdivert_load="YES"` to `/boot/loader.conf` to load the necessary kernel module. Set `net.inet.ip.fw.default_to_accept=1` to allow traffic by default. ```bash ipdivert_load="YES" net.inet.ip.fw.default_to_accept=1 ``` -------------------------------- ### Show nftables Rules Source: https://github.com/bol-van/zapret/blob/master/docs/nftables.txt Display the current nftables rules for the 'inet ztest' table. ```bash nft list table inet ztest ``` -------------------------------- ### NFQWS TCP and UDP Port Targets for Limited Interception Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Defines TCP and UDP ports for limited interception by NFQWS, using the connbytes mechanism. This intercepts only the starting packets of connections. ```shell NFQWS_PORTS_TCP=80,443 NFQWS_PORTS_UDP=443 ``` -------------------------------- ### Compile Zapret Sources on OpenBSD Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Use this command to compile the Zapret sources on OpenBSD. This command is specific to OpenBSD systems. ```bash make bsd ``` -------------------------------- ### Push and Execute tpws on Android (Rootless) Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md This snippet demonstrates how to push the tpws binary to a temporary directory on Android and make it executable, allowing it to be run from any app without root privileges. It includes necessary permission and SELinux context changes. ```bash mkdir /data/local/tmp/zapret adb push tpws /data/local/tmp/zapret chmod 755 /data/local/tmp/zapret /data/local/tmp/zapret/tpws chcon u:object_r:system_file:s0 /data/local/tmp/zapret/tpws ``` -------------------------------- ### Create Scheduled Task for Winws Source: https://github.com/bol-van/zapret/blob/master/docs/windows.en.md Example of a batch script to create a scheduled task for winws. The winws parameters should be configured in the %WINWS1% variable within the script. This must be run as administrator. ```batch @echo off set WINWS1=%%ProgramFiles%%\\zapret-win-bundle\\zapret-winws\\winws.exe -d REM Create scheduled task SchTasks /Create /TN winws1 /TR "%WINWS1%" /SC ONSTART /RU SYSTEM /F REM Start the task SchTasks /Start /TN winws1 echo Scheduled task 'winws1' created and started. ``` -------------------------------- ### Schedule Zapret Table Updates Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Add a cron job to periodically update Zapret tables using the `get_config.sh` script. This example runs the update every two days at noon. ```bash crontab -e 0 12 */2 * * /opt/zapret/ipset/get_config.sh ``` -------------------------------- ### List Zapret nftables Table Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Displays the contents of the 'inet zapret' nftables table. This command is useful for inspecting the current state of Zapret's nftables rules. ```bash /opt/zapret/init.d/sysv/zapret list_table ``` -------------------------------- ### Create NFTables Table and Postrouting Chain Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md This section sets up the 'ztest' table and a 'postnat' chain for postrouting. It's crucial for marking packets after NAT to ensure they are not invalidated by conntrack. ```bash nft create table inet ztest nft add chain inet ztest postnat "{type filter hook postrouting priority srcnat+1;}" ``` -------------------------------- ### PF Redirection Rules for IPv4 and IPv6 Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.md Example pf.conf rules for redirecting incoming traffic on specific ports to a local or link-local address. Note the IPv6 redirection to a link-local address. ```pf rdr pass on em1 inet6 proto tcp to port {80,443} -> fe80::31c:29ff:dee2:1c4d port 988 rdr pass on em1 inet proto tcp to port {80,443} -> 127.0.0.1 port 988 ``` -------------------------------- ### List Zapret nftables Interface Sets Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Lists the interface sets used by Zapret's nftables configuration, such as lanif, wanif, wanif6, and flow table. ```bash /opt/zapret/init.d/sysv/zapret list_ifsets ``` -------------------------------- ### Zapret TPWS Client MSS and Tampering Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Set client MSS with --mss to force server-side message splitting, impacting speed. Control tampering start and cutoff points with --tamper-start and --tamper-cutoff. ```bash --mss= ``` ```bash --tamper-start=[n] ``` ```bash --tamper-cutoff=[n] ``` -------------------------------- ### Zapret TPWS Daemonization and User Privileges Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Run Zapret as a daemon using --daemon. Specify PID file with --pidfile, and drop privileges using --user or --uid. ```bash --daemon ``` ```bash --pidfile= ``` ```bash --user= ``` ```bash --uid=uid[:gid1,gid2,...] ``` -------------------------------- ### Compile Zapret Sources on MacOS Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Use this command to compile the Zapret sources on MacOS. This command is specific to MacOS systems. ```bash make mac ``` -------------------------------- ### MacOS PF Configuration for Passthrough and Outgoing Traffic Source: https://github.com/bol-van/zapret/blob/master/docs/bsd.en.md Configure PF for transparent proxying of both passthrough and outgoing TCP traffic on ports 80 and 443. This setup involves redirecting traffic on a specific LAN interface (en1) and the loopback interface (lo0). It requires tpws to run as root and specifies redirection targets. Ensure the correct LAN interface and link-local address are used. ```shell ifconfig en1 | grep fe80 inet6 fe80::bbbb:bbbb:bbbb:bbbb%en1 prefixlen 64 scopeid 0x8 ``` ```pf.conf rdr pass on en1 inet proto tcp from any to any port {80,443} -> 127.0.0.1 port 988 rdr pass on en1 inet6 proto tcp from any to any port {80,443} -> fe80::bbbb:bbbb:bbbb:bbbb port 988 rdr pass on lo0 inet proto tcp from !127.0.0.0/8 to any port {80,443} -> 127.0.0.1 port 988 rdr pass on lo0 inet6 proto tcp from !::1 to any port {80,443} -> fe80::1 port 988 pass out route-to (lo0 127.0.0.1) inet proto tcp from any to any port {80,443} user { >root } pass out route-to (lo0 fe80::1) inet6 proto tcp from any to any port {80,443} user { >root } ``` ```bash /opt/zapret/tpws/tpws --user=root --port=988 --bind-addr=127.0.0.1 --bind-iface6=lo0 --bind-linklocal=force --bind-iface6=en1 --bind-linklocal=force ``` -------------------------------- ### Load PF Configuration Source: https://github.com/bol-van/zapret/blob/master/docs/bsdfw.txt Command to load the PF configuration file. This applies the rules defined in /etc/pf.conf. ```bash pfctl -f /etc/pf.conf ``` -------------------------------- ### Compile Packages (Static Build) Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Compiles specified packages for static linking within the OpenWrt environment. This uses CFLAGS=-static. ```bash make CFLAGS=-static package/{tpws,nfqws,mdig,ip2net}/compile ``` -------------------------------- ### Compile Packages (Dynamic Build) Source: https://github.com/bol-van/zapret/blob/master/docs/compile/build_howto_openwrt.txt Compiles specified packages for dynamic linking within the OpenWrt environment. ```bash make package/{tpws,nfqws,mdig,ip2net}/compile ``` -------------------------------- ### Import tpws WSL distribution Source: https://github.com/bol-van/zapret/blob/master/docs/windows.en.md Command to import the tpws WSL distribution from a tarball to a specified user profile directory. ```bash wsl --import tpws "%USERPROFILE%\tpws" tpws_wsl.tgz ``` -------------------------------- ### Enable Init Script for Firewall Rules Source: https://github.com/bol-van/zapret/blob/master/docs/readme.en.md Enables the init script to independently apply iptables rules. Not applicable to OpenWrt with firewall3+iptables. ```shell INIT_APPLY_FW=1 ``` -------------------------------- ### Windows Path Notations in Cygwin Source: https://github.com/bol-van/zapret/blob/master/docs/windows.en.md Demonstrates different ways to specify Windows paths within a Cygwin command prompt. Backslashes need to be doubled, or Cygwin's path notation can be used. ```shell cd "C:\\Users\\vasya" ``` ```shell cd "C:/Users/vasya" ``` ```shell cd "/cygdrive/c/Users/vasya" ```