Commit 4ce93e3
committed
feat: add -N flag to run inside an existing named network namespace
Adds a -N NAME option that launches the wrapped program inside a
pre-existing Linux network namespace (e.g. one set up by the new
netns-sandbox.sh, which routes all traffic through a WireGuard VPN).
Unlike -n, which only unshares/shares the host net, -N keeps the
target namespace's network so the sandboxed process inherits the
namespace's routing, firewall, and VPN-provided DNS. To enter it, wrap
prefixes the launch with 'sudo ip netns exec NAME sudo -u $USER',
dropping back to the invoking user before exec'ing bwrap.
Because the process lives in the namespace's net, -N must not unshare
net: it sets unshare_all=0 and explicitly unshares everything else
(ipc, pid, uts, plus user/cgroup best-effort), mirroring the default
set minus net. It also implies the network binds (resolv.conf, ssl) so
DNS and TLS work, relying on the kernel exposing
/etc/netns/NAME/resolv.conf as /etc/resolv.conf inside the namespace.
Documents the flag under ADVANCED OPTIONS in usage and README.1 parent 335de9d commit 4ce93e3
2 files changed
Lines changed: 45 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
76 | 76 | | |
77 | 77 | | |
78 | 78 | | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
79 | 84 | | |
80 | 85 | | |
81 | 86 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
140 | 140 | | |
141 | 141 | | |
142 | 142 | | |
143 | | - | |
144 | | - | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
145 | 150 | | |
146 | 151 | | |
147 | 152 | | |
| |||
173 | 178 | | |
174 | 179 | | |
175 | 180 | | |
| 181 | + | |
176 | 182 | | |
177 | | - | |
| 183 | + | |
178 | 184 | | |
179 | 185 | | |
180 | 186 | | |
| |||
270 | 276 | | |
271 | 277 | | |
272 | 278 | | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
273 | 301 | | |
274 | 302 | | |
275 | 303 | | |
| |||
383 | 411 | | |
384 | 412 | | |
385 | 413 | | |
386 | | - | |
| 414 | + | |
| 415 | + | |
| 416 | + | |
| 417 | + | |
| 418 | + | |
| 419 | + | |
| 420 | + | |
| 421 | + | |
| 422 | + | |
387 | 423 | | |
388 | 424 | | |
389 | 425 | | |
| |||
0 commit comments