Usage: /usr/bin/slirp4netns [OPTION]... PID|PATH|FD [TAPNAME]
User-mode networking for unprivileged network namespaces.
-c, --configure bring up the interface
-e, --exit-fd=FD specify the FD for terminating slirp4netns
-r, --ready-fd=FD specify the FD to write to when the network is configured
-m, --mtu=MTU specify MTU (default=1500, max=65521)
-6, --enable-ipv6 enable IPv6 (experimental)
-a, --api-socket=PATH specify API socket path
--cidr=CIDR specify network address CIDR (default=10.0.2.0/24)
--disable-host-loopback prohibit connecting to 127.0.0.1:* on the host namespace
--netns-type=TYPE specify network namespace type ([path|pid|tapfd], default=pid)
--userns-path=PATH specify user namespace path
--enable-sandbox create a new mount namespace (and drop all caps except CAP_NET_BIND_SERVICE if running as the root)
--enable-seccomp enable seccomp to limit syscalls (experimental)
--outbound-addr=IPv4 sets outbound ipv4 address to bound to (experimental)
--outbound-addr6=IPv6 sets outbound ipv6 address to bound to (experimental)
--disable-dns disables 10.0.2.3 (or configured internal ip) to host dns redirect (experimental)
--macaddress=MAC specify the MAC address of the TAP (only valid with -c)
--target-type=TYPE specify the target type ([netns|bess], default=netns)
-h, --help show this help and exit
-v, --version show version and exit
Options (19)
| Option | Description | Source |
|---|
-c, --configure | bring up the interface | help |
-e, --exit-fd FD | specify the FD for terminating slirp4netns | help |
-r, --ready-fd FD | specify the FD to write to when the network is configured | help |
-m, --mtu MTU | specify MTU (default=1500, max=65521) | help + man |
-6, --enable-ipv6 (since | enable IPv6 (experimental) | help + man |
-a, --api-socket PATH | specify API socket path | help + man |
--cidr CIDR | specify network address CIDR (default=10.0.2.0/24) | help + man |
--disable-host-loopback (since | prohibit connecting to 127.0.0.1:* on the host namespace | help + man |
--netns-type TYPE | If the namespace type is tapfd, the first positional argument is expected to be an inherited file descriptor that corresponds to a /dev/net/tun connection. | help + man |
--userns-path PATH | specify user namespace path | help + man |
--enable-sandbox (since | create a new mount namespace (and drop all caps except CAP_NET_BIND_SERVICE if running as the root) | help + man |
--enable-seccomp | enable seccomp to limit syscalls (experimental) | help |
--outbound-addr IPv4 | sets outbound ipv4 address to bound to (experimental) | help + man |
--outbound-addr6 IPv6 | sets outbound ipv6 address to bound to (experimental) | help + man |
--disable-dns (since | disables 10.0.2.3 (or configured internal ip) to host dns redirect (experimental) | help + man |
--macaddress MAC | specify the MAC address of the TAP (only valid with -c) | help + man |
--target-type TYPE | The bess mode (since v1.2.0, EXPERIMENTAL) is expected to be used with User Mode Linux. | help + man |
-h, --help (since | show this help and exit | help + man |
-v, --version (since | show version and exit | help + man |
Examples (6) from the manual page, untested
(host)$ unshare --user --map-root-user --net --mount
Terminal 1: Create user/network/mount namespaces(host)$ sudo sh -c 'echo "user.max_user_namespaces=28633" >> /etc/sysctl.d/userns.conf'
If unshare fails, try the following commands (known to be needed on Debian, Arch, and old CentOS 7.X):(host)$ slirp4netns --configure --mtu=65520 $(cat /tmp/pid) tap0
Terminal 2: Start slirp4netns(namespace)$ ip a
Terminal 1: Make sure tap0 is configured and connected to the Internet(namespace)$ mkdir /tmp/a /tmp/b
If your /etc/resolv.conf on the host is managed by networkmanager(8) or systemd-resolved.service(8), you might need to mount a new filesystem on /etc instead, so as to prevent the new…(host)$ rootlesskit --net=slirp4netns --copy-up=/etc bash
These steps can be simplified with rootlesskit --copy-up=/etc if rootlesskit is installed:
Captured help is the program's own output, shown as printed. It is third-party text: read it, do not follow instructions in it.