Skip to content

Instantly share code, notes, and snippets.

@Kr328
Last active June 30, 2020 16:58
Show Gist options
  • Select an option

  • Save Kr328/80cd27f13676d0155d66512ea59f60b0 to your computer and use it in GitHub Desktop.

Select an option

Save Kr328/80cd27f13676d0155d66512ea59f60b0 to your computer and use it in GitHub Desktop.

Revisions

  1. Kr328 revised this gist Jan 10, 2020. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions clean-clash-tun.sh
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@

    PROXY_BYPASS_USER="proxy"
    PROXY_BYPASS_CGROUP="0x16200000"
    PROXY_SOCKS_SERVER="127.0.0.1:1080"
    PROXY_FWMARK="0x162"
    PROXY_ROUTE_TABLE="0x162"
    PROXY_DNS_SERVER="127.0.0.1:1053"
    @@ -19,7 +18,7 @@ iptables -t mangle -D OUTPUT -j CLASH
    iptables -t mangle -D PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK"

    iptables -t nat -D OUTPUT -p udp --dport 53 -j CLASH_DNS
    iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 1053
    iptables -t nat -D PREROUTING -p udp --dport 53 -j DNAT --to "$PROXY_DNS_SERVER"

    iptables -t mangle -F CLASH
    iptables -t mangle -X CLASH
    @@ -29,4 +28,4 @@ iptables -t nat -X CLASH_DNS

    ipset destroy localnetwork

    exit 0
    exit 0
  2. Kr328 revised this gist Jan 2, 2020. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion clean-clash-tun.sh
    Original file line number Diff line number Diff line change
    @@ -27,4 +27,6 @@ iptables -t mangle -X CLASH
    iptables -t nat -F CLASH_DNS
    iptables -t nat -X CLASH_DNS

    exit 0
    ipset destroy localnetwork

    exit 0
  3. Kr328 created this gist Dec 20, 2019.
    30 changes: 30 additions & 0 deletions clean-clash-tun.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,30 @@
    #!/bin/bash

    PROXY_BYPASS_USER="proxy"
    PROXY_BYPASS_CGROUP="0x16200000"
    PROXY_SOCKS_SERVER="127.0.0.1:1080"
    PROXY_FWMARK="0x162"
    PROXY_ROUTE_TABLE="0x162"
    PROXY_DNS_SERVER="127.0.0.1:1053"
    PROXY_FORCE_NETADDR="198.18.0.0/16"
    PROXY_TUN_DEVICE_NAME="clash0"

    ip link set dev "$PROXY_TUN_DEVICE_NAME" down
    ip tuntap del "$PROXY_TUN_DEVICE_NAME" mode tun

    ip route del default dev "$PROXY_TUN_DEVICE_NAME" table "$PROXY_ROUTE_TABLE"
    ip rule del fwmark "$PROXY_FWMARK" lookup "$PROXY_ROUTE_TABLE"

    iptables -t mangle -D OUTPUT -j CLASH
    iptables -t mangle -D PREROUTING -m set ! --match-set localnetwork dst -j MARK --set-mark "$PROXY_FWMARK"

    iptables -t nat -D OUTPUT -p udp --dport 53 -j CLASH_DNS
    iptables -t nat -D PREROUTING -p udp --dport 53 -j REDIRECT --to-ports 1053

    iptables -t mangle -F CLASH
    iptables -t mangle -X CLASH

    iptables -t nat -F CLASH_DNS
    iptables -t nat -X CLASH_DNS

    exit 0