You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: USERGUIDE.md
+90-36
Original file line number
Diff line number
Diff line change
@@ -61,29 +61,55 @@ Note that the values are case-sensitive. If you use a custom config file
61
61
then you should not set the provider or server (setting the protocol is
62
62
also optional).
63
63
64
-
The current network namespace name is provided to the PostUp and PreDown
65
-
scripts in the environment variable `$VOPONO_NS`. It is temporarily set
66
-
when running these scripts only.
64
+
### PostUp and PreDown scripts - run on Host (outside network namespace)
67
65
68
-
Similarly, the network namespace IP address is provided via `$VOPONO_NS_IP`,
69
-
and is available to the PostUp and PreDown scripts, and the application to
70
-
run itself. `$VOPONO_NS_IP` is useful if you'd like to configure a server
66
+
vopono can run scripts on the host machine (outside the network namespace) with the `--postup` and `--predown` arguments (or setin the `~/.config/vopono/config.toml` file). The postup script will run right after the network namespace is set up (also after provider port forwarding if used), the postdown script will run when tearing down the network namespace after the target application has terminated.
67
+
68
+
These scripts run outside of the network namespace so that they can be used to run proxies and DNS services which the network namespace can use. To run extra commands within the network namespace, you can just wrap the target command with your own script (see the Plex example below).
69
+
70
+
These scripts run using the current working directory with the same user as the target application itself (which can be set
71
+
with the `user` argument or config file entry).
72
+
73
+
Arguments can be passed to the scripts from the command line (note the escaped spaces if the script path contains spaces), e.g.:
74
+
75
+
```bash
76
+
--postup "~/test\ postup.sh argy1 argy2"
77
+
```
78
+
79
+
e.g. with a script like:
80
+
81
+
```bash
82
+
#!/bin/bash
83
+
echo"arg1: $1 arg2: $2"
84
+
```
85
+
86
+
Just like for the target application execution, the following environment variables are available (but recall that these scripts run *outside* the network namespace):
87
+
88
+
- `$VOPONO_HOST_IP` the local IP address of the host machine as seen from inside the network namespace.
89
+
- `$VOPONO_NS_IP` the local IP address of the network namespace as seen from the host.
90
+
- `$VOPONO_NS` the name of the network namespace.
91
+
- `$VOPONO_FORWARDED_PORT` the forwarded port for provider port forwarding (ProtonVPN or PIA) - only when using `--port-forwarding` or `--custom-port-forwarding`
92
+
93
+
`$VOPONO_NS_IP` is useful if you'd like to configure a server
71
94
running within the network namespace to listen on its local IP address only
72
-
(see below, for more information on that).
95
+
(see below for more information on that).
73
96
74
-
The application to run within the namespace also has access to
75
-
`$VOPONO_HOST_IP`, to get the IP address of the host.
97
+
### Host access from within the network namespace
76
98
77
-
Note: These environment variables are currently only available from within
78
-
the application/script to run, not on the command line. So the following
79
-
doesn't work:
99
+
The host IP address (as seen from inside the network namespace) is provided as the
100
+
`$VOPONO_HOST_IP` environment variable to the target application/script itself (and also the host scripts described above).
If `--allow-host-access` is set then the host machine IP (as seen from the network namespace) is also added to the hosts file as `vopono.host` so you can access services on the host machine from within the network namespace e.g. at `http://vopono.host:8080` etc.
82
103
83
-
Output: `HOST IP: $VOPONO_HOST_IP` (the environ variable wasn't expanded).
104
+
If provider port forwarding is enabled (e.g. `--port-forwarding` or `--custom-port-forwarding` with ProtonVPN or PIA) then the forwarded port is provided as `$VOPONO_FORWARDED_PORT`.
84
105
85
-
A work around is to create a executable script, that executes the
86
-
application you'd like to run:
106
+
### Running commands before and after execution within the network namespace
107
+
108
+
To run extra commands inside the network namespace you can wrap your target application with a bash script and provide that script as the target to vopono.
109
+
110
+
Note that the target user *must* have read and executable access to this script!
111
+
112
+
For example with a simple script using the environment variables (also see the Plex section below):
87
113
88
114
```bash
89
115
#!/bin/bash
@@ -101,32 +127,14 @@ Output:
101
127
=> HOST IP: 10.200.1.1
102
128
```
103
129
104
-
### Host scripts
105
-
106
-
Host scripts to run just after a network namespace is created and just before it is destroyed,
107
-
can be provided with the `postup` and `predown` arguments (or in the `config.toml`).
108
-
109
-
Note these scripts run on the host (outside the network namespace), using the current working directory,
110
-
and with the same user as the final application itself (which can be set
111
-
with the `user` argument or config file entry).
112
-
113
-
Script arguments (e.g. `script.sh arg1 arg1`), are currently not possible, resulting in an error:
114
-
115
-
```
116
-
$ vopono exec {other Vopono options} --postup 'echo POSTUP' ls
117
-
[...]
118
-
sudo: echo POSTUP: command not found
119
-
[...]
120
-
```
121
-
122
130
### Wireguard
123
131
124
132
Install vopono and use `vopono sync` to
125
133
create the Wireguard configuration files (and generate a keypair if
126
134
necessary):
127
135
128
136
```bash
129
-
$ yay -S vopono-git
137
+
$ paru -S vopono-bin
130
138
$ vopono sync
131
139
```
132
140
@@ -159,7 +167,7 @@ Install vopono and use `vopono sync` to
159
167
create the OpenVPN configuration files and server lists.
0 commit comments