mirror of
https://github.com/tun2proxy/tun2proxy.git
synced 2025-06-23 01:20:52 +00:00
Adapt README to new interface
This commit is contained in:
parent
5df3877042
commit
8dd075a7f4
2 changed files with 20 additions and 39 deletions
55
README.md
55
README.md
|
@ -12,22 +12,25 @@ cargo build --release
|
||||||
## Setup
|
## Setup
|
||||||
A standard setup, which would route all traffic from your system through the tunnel interface, could look as follows:
|
A standard setup, which would route all traffic from your system through the tunnel interface, could look as follows:
|
||||||
```shell
|
```shell
|
||||||
# Define the proxy endpoint.
|
# The proxy type can be either SOCKS5 or HTTP.
|
||||||
|
PROXY_TYPE=SOCKS5
|
||||||
PROXY_IP=1.2.3.4
|
PROXY_IP=1.2.3.4
|
||||||
PROXY_PORT=1080
|
PROXY_PORT=1080
|
||||||
|
|
||||||
# Create a tunnel interface named tun0 which your user can bind to, so we don't need to run tun2proxy as root.
|
# Create a tunnel interface named tun0 which your user can bind to,
|
||||||
|
# so we don't need to run tun2proxy as root.
|
||||||
sudo ip tuntap add name tun0 mode tun user $USER
|
sudo ip tuntap add name tun0 mode tun user $USER
|
||||||
sudo ip link set tun0 up
|
sudo ip link set tun0 up
|
||||||
|
|
||||||
# To prevent a routing loop, we add a route to the proxy server that behaves like the default route.
|
# To prevent a routing loop, we add a route to the proxy server that behaves
|
||||||
|
# like the default route.
|
||||||
sudo ip route add "$PROXY_IP" $(ip route | grep '^default' | cut -d ' ' -f 2-)
|
sudo ip route add "$PROXY_IP" $(ip route | grep '^default' | cut -d ' ' -f 2-)
|
||||||
|
|
||||||
# Route all your traffic through tun0 without interfering with the default route.
|
# Route all your traffic through tun0 without interfering with the default route.
|
||||||
sudo ip route add 128.0.0.0/1 dev tun0
|
sudo ip route add 128.0.0.0/1 dev tun0
|
||||||
sudo ip route add 0.0.0.0/1 dev tun0
|
sudo ip route add 0.0.0.0/1 dev tun0
|
||||||
|
|
||||||
./target/release/tun2proxy --tun tun0 --proxy socks5 --addr "$PROXY_IP:$PROXY_PORT"
|
./target/release/tun2proxy --tun tun0 --proxy "$PROXY_TYPE://$PROXY_IP:$PROXY_PORT"
|
||||||
```
|
```
|
||||||
|
|
||||||
Note that if you paste these commands into a shell script, which you then run with `sudo`, you might want to replace
|
Note that if you paste these commands into a shell script, which you then run with `sudo`, you might want to replace
|
||||||
|
@ -36,49 +39,27 @@ Note that if you paste these commands into a shell script, which you then run wi
|
||||||
For DNS to work, you might need an additional tool like [dnsproxy](https://github.com/AdguardTeam/dnsproxy) that is
|
For DNS to work, you might need an additional tool like [dnsproxy](https://github.com/AdguardTeam/dnsproxy) that is
|
||||||
configured to listen on a local UDP port and communicates with the upstream DNS server via TCP.
|
configured to listen on a local UDP port and communicates with the upstream DNS server via TCP.
|
||||||
|
|
||||||
## CLI
|
When you terminate this program and want to eliminate the impact caused by the above several commands,
|
||||||
=======
|
you can execute the following command. The routes will be automatically deleted with the tunnel device.
|
||||||
When you end the running of this program and want to eliminate the impact caused by the above several commands,
|
|
||||||
you can execute the following commands.
|
|
||||||
```shell
|
```shell
|
||||||
sudo ip route del 0.0.0.0/1 dev tun0
|
sudo ip link del tun0
|
||||||
sudo ip route del 128.0.0.0/1 dev tun0
|
|
||||||
sudo ip link set tun0 down
|
|
||||||
sudo ip tuntap del tun0 mode tun
|
|
||||||
```
|
```
|
||||||
|
|
||||||
## CLI
|
## CLI
|
||||||
```
|
```
|
||||||
Tunnel interface to proxy.
|
Tunnel interface to proxy.
|
||||||
|
|
||||||
Usage: tun2proxy [OPTIONS] --tun <name> --proxy <type> --addr <ip:port>
|
Usage: tun2proxy [OPTIONS] --proxy <URL>
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
-t, --tun <name>
|
-t, --tun <name> Name of the tun interface [default: tun0]
|
||||||
Name of the tun interface
|
-p, --proxy <URL> The proxy URL in the form proto://[username[:password]@]host:port
|
||||||
|
-h, --help Print help
|
||||||
-p, --proxy <type>
|
-V, --version Print version
|
||||||
What proxy type to run
|
|
||||||
|
|
||||||
Possible values:
|
|
||||||
- socks5: SOCKS5 server to use
|
|
||||||
- http: HTTP server to use
|
|
||||||
|
|
||||||
-a, --addr <ip:port>
|
|
||||||
Server address with format ip:port
|
|
||||||
|
|
||||||
--username <username>
|
|
||||||
Username for authentication
|
|
||||||
|
|
||||||
--password <password>
|
|
||||||
Password for authentication
|
|
||||||
|
|
||||||
-h, --help
|
|
||||||
Print help (see a summary with '-h')
|
|
||||||
|
|
||||||
-V, --version
|
|
||||||
Print version
|
|
||||||
```
|
```
|
||||||
|
Currently, tun2proxy supports two proxy protocols: HTTP and SOCKS5. A proxy is supplied to the `--proxy` argument in the
|
||||||
|
URL format. For example, an HTTP proxy at 1.2.3.4:1080 with a username of `john.doe` and a password of `secret` is
|
||||||
|
supplied as `--proxy http://john.doe:secret@1.2.3.4:1080`. This works analogously to curl's `--proxy` argument.
|
||||||
|
|
||||||
## TODO
|
## TODO
|
||||||
- UDP support for SOCKS
|
- UDP support for SOCKS
|
||||||
|
|
|
@ -14,8 +14,8 @@ struct Args {
|
||||||
#[arg(short, long, value_name = "name", default_value = "tun0")]
|
#[arg(short, long, value_name = "name", default_value = "tun0")]
|
||||||
tun: String,
|
tun: String,
|
||||||
|
|
||||||
/// What proxy type to run
|
/// The proxy URL in the form proto://[username[:password]@]host:port
|
||||||
#[arg(short, long = "proxy", value_parser = proxy_url_parser)]
|
#[arg(short, long = "proxy", value_parser = proxy_url_parser, value_name = "URL")]
|
||||||
proxy: ArgProxy,
|
proxy: ArgProxy,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue