passt(1)

๐Ÿ’… passt(1) โ€” General Commands Manual ๐Ÿ’…

okay so before we get into it: the manual name is passt, bestie โ€” like, that's the page you're reading right now. Two whole programs live in here (passt and pasta) and they're both iconic in their own way, so let's get into it ๐Ÿ’–


๐ŸŒธ NAME ๐ŸŒธ

  • passt โ€” unprivileged user-mode network connectivity for virtual machines ๐Ÿฆ‹
  • pasta โ€” unprivileged user-mode network connectivity for network namespaces ๐ŸŽ€

๐ŸŒˆ SYNOPSIS ๐ŸŒˆ

passt [OPTION]...
pasta [OPTION]... [COMMAND [ARG]...]
pasta [OPTION]... PID
pasta [OPTION]... --netns [PATH|NAME]

๐Ÿ’œ DESCRIPTION ๐Ÿ’œ

๐Ÿงš passt

okay so passt (short for Plug A Simple Socket Transport, which, slay) gives you full, quasi-native network connectivity to virtual machines in user-mode โ€” and the whole point is it does not require any capabilities or privileges. no cap. zero. ๐Ÿ’…

The data plane implements a translation layer between a Layer-2 virtual network interface and native Layer-4 (TCP, UDP, ping) sockets on the host. The way to think about it: from a networking perspective, it gives the illusion that application processes residing on the guest are actually running on the local host. main character energy, honestly โœจ

There are built-in ARP, DHCP, NDP, and DHCPv6 implementations, and they're designed to hand the guest a network configuration that tightly resembles the host's native configuration. With the default options, guest and host share IP addresses, routes, and port bindings. sharing is caring ๐Ÿซถ

Port forwarding and translation let networking services running in the guest be reachable from both local and remote hosts. literally reachable from everywhere ๐Ÿ”ฅ

Unlike slirp4netns(1), passt doesn't implement a full TCP stack โ€” the TCP translation layer has no stateful data buffering and operates by reflecting one peer's observed parameters (congestion window size, acknowledged data, etc.) to the corresponding peer. it's giving mirror, not memory ๐Ÿ’€

Currently, the only supported hypervisor is qemu(1), which connects to passt by means of a UNIX domain socket. This is supported starting from qemu 7.2. For older qemu versions, see the qrap(1) wrapper. (elder qemu, we love you, but use the wrapper ๐Ÿ™ˆ)

๐ŸŒท pasta

pasta (that's Pack A Subtle Tap Abstraction, if you were wondering โ€” iykyk) provides equivalent functionality to network namespaces, as the one offered by passt for virtual machines. same vibes, different target ๐ŸŽ€

If PID or --netns are given, pasta associates to an existing user and network namespace. Otherwise, pasta creates a new user and network namespace, and spawns the given command or a default shell within this context. A tap device within the network namespace is created to provide network connectivity. it builds the whole set for you, honestly ๐Ÿ‘‘

For local TCP and UDP traffic only, pasta also implements a bypass path directly mapping Layer-4 sockets between init and target namespaces, for performance reasons. shortcut szn ๐ŸŽ๏ธ


โœจ OPTIONS โœจ

Unless otherwise noted below, if conflicting or multiple options are given, the last one takes effect. periodt. ๐Ÿ’…

  • -d, --debug โ€” be verbose, and don't log to the system logger.
  • --trace โ€” be extra verbose, like show single packets verbose ๐Ÿ‘€. Implies --debug.
  • -q, --quiet โ€” don't print informational messages. shhh ๐Ÿคซ
  • -f, --foreground โ€” don't run in background. this implies that the process is not moved to a detached PID namespace after starting, because the PID itself cannot change. Default is to fork into background. ๐ŸŒ€
  • -e, --stderr (DEPRECATED) โ€” this option has no effect, and is maintained for compatibility purposes only.
โš ๏ธ heads up bestie: this configuration option is deprecated and will be removed in a future version. don't get attached ๐Ÿ’€
  • -l, --log-file PATH โ€” log to file PATH, and not to the system logger.

Specifying this option multiple times does not lead to multiple log files: the last given option takes effect. one file, one vibe ๐Ÿ“„

  • --log-size SIZE โ€” limit log file size to SIZE bytes. When the log file is full, make room for new entries by removing old ones at the beginning. This limit is mandatory. Default is 1048576 (1 MiB). ๐Ÿ“
  • --runas UID|UID:GID|LOGIN|LOGIN:GROUP โ€” attempt to change to the given UID and corresponding group if UID is given, or to the given UID and given GID if both are given. Alternatively, login name, or login name and group name can be passed. This requires privileges (either initial effective UID 0 or CAP_SETUID capability) to work. Default is to change to user nobody if started as root. ๐Ÿ‘‘
  • -h, --help โ€” display a help message and exit. we love a helper ๐Ÿซถ
  • --version โ€” show version and exit. โญ
  • -p, --pcap file โ€” capture tap-facing (that is, guest-side or namespace-side) network packets to file in pcap format. ๐Ÿ“ผ

Specifying this option multiple times does not lead to multiple capture files: the last given option takes effect.

  • -P, --pid file โ€” write own PID to file once initialisation is done, before forking to background (if configured to do so). ๐ŸŽ€
  • -m, --mtu mtu โ€” assign mtu via DHCP (option 26) and NDP (option type 5). A zero value disables assignment. By default, the advertised MTU is 65520 bytes, that is, the maximum 802.3 MTU minus the length of a 802.3 header, rounded to 32 bits (IPv4 words). big packet energy ๐Ÿ”ฅ
  • -a, --address addr โ€” assign IPv4 addr via DHCP (yiaddr), or addr via DHCPv6 (option 5) and an addr-based prefix via NDP Router Advertisement (option type 3) for an IPv6 addr. This option can be specified zero (for defaults) to two times (once for IPv4, once for IPv6). By default, assigned IPv4 and IPv6 addresses are taken from the host interfaces with the first default route, if any, for the corresponding IP version. If no default routes are available and there is any interface with any route for a given IP version, the first of these interfaces will be chosen instead. If no such interface exists, the link-local address 169.254.2.1 is assigned for IPv4, and no additional address will be assigned for IPv6. ๐Ÿก
  • -n, --netmask mask โ€” assign IPv4 netmask mask, expressed as dot-decimal or number of bits, via DHCP (option 1). By default, the netmask associated to the host address matching the assigned one is used. If there's no matching address on the host, the netmask is determined according to the CIDR block of the assigned address (RFC 4632). ๐ŸŒˆ
  • -M, --mac-addr addr โ€” use source MAC address addr when communicating to the guest or to the target namespace. Default is the locally administered MAC addresses 9a:55:9a:55:9a:55. yes that really is the default, and honestly? iconic ๐Ÿ’…
  • -g, --gateway addr โ€” assign IPv4 addr as default gateway via DHCP (option 3), or IPv6 addr as source for NDP Router Advertisement and DHCPv6 messages. This option can be specified zero (for defaults) to two times (once for IPv4, once for IPv6). By default, IPv4 and IPv6 gateways are taken from the host interface with the first default route, if any, for the corresponding IP version. If the default route is a multipath one, the gateway is the first nexthop router returned by the kernel which has the highest weight in the set of paths. If no default routes are available and there is just one interface with any route, that interface will be chosen instead. If no such interface exists, the link-local address 169.254.2.2 is used for IPv4, and the link-local address fe80::1 is used for IPv6. ๐Ÿšช
๐Ÿ“Œ Note: these addresses are also used as source address for packets directed to the guest or to the target namespace having a loopback or local source address, to allow mapping of local traffic to guest and target namespace. See the NOTES below for more details about this mechanism.
  • -i, --interface name โ€” use host interface name to derive addresses and routes. Default is to use the interfaces specified by --outbound-if4 and --outbound-if6, for IPv4 and IPv6 addresses and routes, respectively. ๐Ÿฆ‹

If no interfaces are given, the interface with the first default routes for each IP version is selected. If no default routes are available and there is just one interface with any route, that interface will be chosen instead. If no such interface exists, host interfaces will be ignored for the purposes of assigning addresses and routes, and link-local addresses will be used instead.

  • -o, --outbound addr โ€” use an IPv4 addr as source address for IPv4 outbound TCP connections, UDP flows, ICMP requests, or an IPv6 addr for IPv6 ones, by binding outbound sockets to it. This option can be specified zero (for defaults) to two times (once for IPv4, once for IPv6). By default, the source address is selected by the routing tables. ๐Ÿ—บ๏ธ
  • --outbound-if4 name โ€” bind IPv4 outbound sockets to host interface name, and, unless another interface is specified via -i, --interface, use this interface to derive IPv4 addresses and routes. ๐Ÿ’™

By default, the interface given by the default route is selected. If no default routes are available and there is just one interface with any route, that interface will be chosen instead. If no such interface exists, outbound sockets will not be bound to any specific interface.

  • --outbound-if6 name โ€” bind IPv6 outbound sockets to host interface name, and, unless another interface is specified via -i, --interface, use this interface to derive IPv6 addresses and routes. ๐Ÿ’œ

By default, the interface given by the default route is selected. If no default routes are available and there is just one interface with any route, that interface will be chosen instead. If no such interface exists, outbound sockets will not be bound to any specific interface.

  • -D, --dns addr โ€” instruct the guest (via DHCP, DHCPv6 or NDP) to use addr (IPv4 or IPv6) as a nameserver, as configured (see options --no-dhcp-dns, --dhcp-dns) instead of reading addresses from /etc/resolv.conf. This option can be specified multiple times. Specifying -D none disables usage of DNS addresses altogether. Unlike addresses from /etc/resolv.conf, addr is given to the guest without remapping. For example --dns 127.0.0.1 will instruct the guest to use itself as nameserver, not the host. ๐Ÿงš
  • --dns-forward addr โ€” map addr (IPv4 or IPv6) as seen from guest or namespace to the nameserver (with corresponding IP version) specified by the --dns-host option. Maps only UDP and TCP traffic to port 53 or port 853. Replies are translated back with a reverse mapping. This option can be specified zero to two times (once for IPv4, once for IPv6). ๐Ÿ”
  • --dns-host addr โ€” configure the host nameserver which guest or namespace queries to the --dns-forward address will be redirected to. This option can be specified zero to two times (once for IPv4, once for IPv6). By default, the first nameserver from the host's /etc/resolv.conf. ๐Ÿ“
  • -S, --search list โ€” bestie, this one feeds your DHCP, DHCPv6, and NDP a space-separated list instead of making them go read entries out of /etc/resolv.conf. Wanna know the โœจloreโœจ? Check --no-dhcp-search and --dhcp-search below. And heads up: --search none straight-up disables the DNS domain search list entirely โ€” so if you actually need to search a domain literally called "none", write --search none. (with the dot, periodt).
  • --no-dhcp-dns โ€” passt mode behavior: don't hand out IPv4 addresses via DHCP (option 23), and don't hand out IPv6 addresses via NDP Router Advertisement (option type 25) and DHCPv6 (option 23), as DNS resolvers. By default, all the configured addresses are passed. ๐Ÿ’…
  • --dhcp-dns โ€” pasta mode behavior: do hand out IPv4 addresses via DHCP (option 23), or IPv6 addresses via NDP Router Advertisement (option type 25) and DHCPv6 (option 23), as DNS resolvers. By default, configured addresses, if any, are not passed. ๐Ÿ™ˆ
  • --no-dhcp-search โ€” passt mode: don't send the DNS domain search list addresses via DHCP (option 119), via NDP Router Advertisement (option type 31), and DHCPv6 (option 24). By default, the DNS domain search list resulting from configuration is passed. ๐ŸŽ€
  • --dhcp-search โ€” pasta mode: do send the DNS domain search list addresses via DHCP (option 119), via NDP Router Advertisement (option type 31), and DHCPv6 (option 24). By default, the DNS domain search list resulting from configuration is not passed. ๐Ÿฆ‹
  • --no-tcp โ€” kills the TCP protocol handler. No TCP connections will be accepted host-side, and TCP packets coming from the guest or target namespace will be silently dropped. ๐Ÿ’€
  • --no-udp โ€” kills the UDP protocol handler. No UDP traffic coming from the host side will be forwarded, and UDP packets coming from guest or target namespace will be silently dropped. ๐Ÿ’€
  • --no-icmp โ€” kills the ICMP/ICMPv6 echo handler. ICMP and ICMPv6 echo requests coming from guest or target namespace will be silently dropped. ๐Ÿ’€
  • --no-dhcp โ€” kills the DHCP server. DHCP client requests coming from guest or target namespace will be silently dropped. This one's implied if there's no gateway on the selected IPv4 default route, iykyk.
  • --no-ndp โ€” disables NDP responses. NDP messages coming from guest or target namespace will be ignored. ๐Ÿซฅ
  • --no-dhcpv6 โ€” kills the DHCPv6 server. DHCPv6 client requests coming from guest or target namespace will be silently dropped. ๐Ÿ’€
  • --no-ra โ€” disables Router Advertisements. Router Solicitations coming from guest or target namespace will be ignored. ๐Ÿซฅ
  • --freebind โ€” lets you bind literally any address you want for the -t and -u options. Normally, binding addresses must be addresses currently configured on the host, but with --freebind the IP_FREEBIND or IPV6_FREEBIND socket option gets enabled, allowing any address to be used. It's giving manifesting your future network config โ€” this is typically used to bind addresses which might be configured on the host in future, at which point the forwarding will immediately start operating. โœจ
  • --map-host-loopback addr โ€” translates addr to refer to the host. Packets from the guest to addr will be redirected to the host. On the host, such packets will appear to have both source and destination of 127.0.0.1 or ::1. ๐ŸŒ€

If addr is 'none', no address is mapped (this implies --no-map-gw). Only one IPv4 and one IPv6 address can be translated; if the option is specified multiple times, the last one takes effect.

Default is to translate the guest's default gateway address, unless --no-map-gw is given, in which case no address is mapped.

  • --no-map-gw โ€” don't remap TCP connections and untracked UDP traffic, with the gateway address as destination, to the host. Implied if there's no gateway on the selected default route, or if there's no default route, for any of the enabled address families. ๐Ÿšซ
  • --map-guest-addr addr โ€” translates addr in the guest to be equal to the guest's assigned address on the host. That is, packets from the guest to addr will be redirected to the address assigned to the guest with -a, or by default the host's global address. This allows the guest to access services available on the host's global address, even though its own address shadows that of the host. ๐Ÿคฏ

If addr is 'none', no address is mapped. Only one IPv4 and one IPv6 address can be translated, and if the option is specified multiple times, the last one for each address type takes effect.

By default, mapping happens as described for the --map-host-loopback option.

  • -4, --ipv4-only โ€” enables IPv4-only operation. IPv6 traffic will be ignored. By default, IPv6 operation is enabled as long as at least an IPv6 route and an interface address are configured on a given host interface. ๐Ÿ“
  • -6, --ipv6-only โ€” enables IPv6-only operation. IPv4 traffic will be ignored. By default, IPv4 operation is enabled as long as at least an IPv4 route and an interface address are configured on a given host interface. ๐Ÿ“
  • -H, --hostname name โ€” the hostname to configure the client with. Sends name as DHCP option 12 (hostname). ๐Ÿท๏ธ
  • --fqdn name โ€” the FQDN to configure the client with. Sends name as Client FQDN: DHCP option 81 and DHCPv6 option 39. ๐Ÿ‘‘

๐Ÿซถ passt-only options ๐Ÿซถ

These ones are for when you're running the passt life, bestie โ€” the qemu-adjacent era.

  • -s, --socket-path, --socket path โ€” path for the UNIX domain socket used by qemu(1) or qrap(1) to connect to passt. Default is to probe a free socket, not accepting connections, starting from /tmp/passt_1.socket to /tmp/passt_64.socket. ๐Ÿ”Œ
  • --vhost-user โ€” enables vhost-user. The vhost-user command socket is provided by --socket. ๐Ÿ’ซ
  • --print-capabilities โ€” prints back-end capabilities in JSON format. Only meaningful for vhost-user mode, ngl. ๐Ÿ“‹
  • --repair-path path โ€” path for the UNIX domain socket used by the passt-repair(1) helper to connect to passt in order to set or clear the TCP_REPAIR option on sockets, during migration. --repair-path none disables this interface (if you need to specify a socket path called "none" you can prefix the path by ./). ๐Ÿฉน

Default, for --vhost-user mode only, is to append .repair to the path chosen for the hypervisor UNIX domain socket. No socket is created if not in --vhost-user mode.

  • -F, --fd FD โ€” passes a pre-opened, connected socket to passt. Usually the socket is opened in the parent process and passt inherits it when run as a child. This allows the parent process to open sockets using another address family or requiring special privileges. ๐ŸŽ

This option implies the behaviour described for --one-off, once this socket is closed.

  • -1, --one-off โ€” quit after handling a single client connection, that is, once the client closes the socket, or once we get a socket error. One and done, no strings attached. โœŒ๏ธ
  • -t, --tcp-ports spec โ€” configures TCP port forwarding to the guest. spec can be one of:
    • none โ€” don't forward any ports ๐Ÿ™…
    • all โ€” forward all unbound, non-ephemeral ports, as permitted by current capabilities. For low (< 1024) ports, see NOTES. No failures are reported for unavailable ports, unless no ports could be forwarded at all. ๐ŸŒˆ
    • ports โ€” a comma-separated list of ports, optionally ranged with -, and, optionally, with target ports after :, if they differ. Specific addresses can be bound as well, separated by /, and also, since Linux 5.7, limited to specific interfaces, prefixed by %. Within given ranges, selected ports and ranges can be excluded by an additional specification prefixed by ~. ๐ŸŽฏ

Specifying excluded ranges only implies that all other ports are forwarded. In this case, no failures are reported for unavailable ports, unless no ports could be forwarded at all.

Examples, bestie โ€” bookmark these fr fr:

  • -t 22 โ€” forward local port 22 to port 22 on the guest
  • -t 22:23 โ€” forward local port 22 to port 23 on the guest
  • -t 22,25 โ€” forward local ports 22 and 25 to ports 22 and 25 on the guest
  • -t 22-80 โ€” forward local ports between 22 and 80 to corresponding ports on the guest
  • -t 22-80:32-90 โ€” forward local ports between 22 and 80 to ports between 32 and 90 on the guest
  • -t 192.0.2.1/22 โ€” forward local port 22, bound to 192.0.2.1, to port 22 on the guest
  • -t 192.0.2.1%eth0/22 โ€” forward local port 22, bound to 192.0.2.1 and interface eth0, to port 22
  • -t %eth0/22 โ€” forward local port 22, bound to any address on interface eth0, to port 22
  • -t 2000-5000,~3000-3010 โ€” forward local ports between 2000 and 5000, except for those between 3000 and 3010
  • -t 192.0.2.1/20-30,~25 โ€” for the local address 192.0.2.1, forward ports between 20 and 24 and between 26 and 30
  • -t ~20000-20010 โ€” forward all ports to the guest, except for the range from 20000 to 20010

Default is none.

  • -u, --udp-ports spec โ€” configures UDP port forwarding to the guest. spec is exactly as described for TCP above. ๐Ÿ›ฐ๏ธ
Note: unless overridden, UDP ports with numbers corresponding to forwarded TCP port numbers are forwarded too, without, however, any port translation. IPv6 bound ports are also forwarded for IPv4. ๐Ÿซถ

Default is none.


๐ŸŒธ pasta-only options ๐ŸŒธ

And these are the pasta-mode exclusives โ€” different vibe, same excellence.

  • -I, --ns-ifname name โ€” name of the tap interface to be created in the target namespace. By default, the same interface name as the external, routable interface is used. If no such interface exists, the name tap0 will be used instead. ๐Ÿงš
  • -t, --tcp-ports spec โ€” configures TCP port forwarding to the namespace. spec can be one of:
    • none โ€” don't forward any ports ๐Ÿ™…
  • auto โ€” the โœจmagicโœจ one: forwards ports that are bound inside the namespace, dynamically. It re-checks every second, pulling the list of ports straight from the listening sockets reported by /proc/net/tcp and /proc/net/tcp6 โ€” see proc(5) if you wanna know how that's cooked ๐Ÿ“
  • ports โ€” a comma-separated list of ports, bestie. You can range them with -, and if the target port is different you slap it on after a : . Wanna bind a specific address? Separate it with /. And since Linux 5.7 you can even limit it to specific interfaces by prefixing with % ๐Ÿ’… And when you've got ranges, you can exclude selected ports and ranges by adding another spec prefixed with ~.

Real talk though โ€” if you only specify excluded ranges, that implies everything else is forwarded. In that case, no failures get reported for ports that aren't available, unless literally zero ports could be forwarded at all ๐Ÿ˜ญ

Examples, and yes you should bookmark these:

  • -t 22 โ€” forward local port 22 to 22 in the target namespace
  • -t 22:23 โ€” forward local port 22 to port 23 in the target namespace
  • -t 22,25 โ€” forward local ports 22 and 25 to ports 22 and 25 in the target namespace
  • -t 22-80 โ€” forward local ports between 22 and 80 to corresponding ports in the target namespace
  • -t 22-80:32-90 โ€” forward local ports between 22 and 80 to ports between 32 and 90 in the target namespace
  • -t 192.0.2.1/22 โ€” forward local port 22, bound to 192.0.2.1, to port 22 in the target namespace
  • -t 192.0.2.1%eth0/22 โ€” forward local port 22, bound to 192.0.2.1 and interface eth0, to port 22
  • -t %eth0/22 โ€” forward local port 22, bound to any address on interface eth0, to port 22
  • -t 2000-5000,~3000-3010 โ€” forward local ports between 2000 and 5000, except for those between 3000 and 3010
  • -t 192.0.2.1/20-30,~25 โ€” for the local address 192.0.2.1, forward ports between 20 and 24 and between 26 and 30
  • -t ~20000-20010 โ€” forward all ports to the namespace, except for those between 20000 and 20010

Also! IPv6 bound ports get forwarded for IPv4 too ๐ŸŒˆ

Default is auto.

  • -u, --udp-ports spec โ€” sets up UDP port forwarding to the namespace. The spec is literally the same as described for TCP above, and the port list this time comes from listening sockets reported by /proc/net/udp and /proc/net/udp6 โ€” again, see proc(5) ๐Ÿงš
Heads up: unless you override it, UDP ports whose numbers match forwarded TCP port numbers get forwarded too โ€” but with no port translation whatsoever. Periodt.

IPv6 bound ports are also forwarded for IPv4.

Default is auto.

  • -T, --tcp-ns spec โ€” configures TCP port forwarding going the other way: from the target namespace to the init namespace ๐Ÿ‘‘ spec works as described above for TCP.

Default is auto.

  • -U, --udp-ns spec โ€” configures UDP port forwarding from the target namespace to the init namespace. spec is as described above for UDP.

Default is auto.

  • --host-lo-to-ns-lo โ€” if you pass this, connections forwarded with -t and -u that come from the host's loopback address will show up on the loopback address in the guest as well ๐Ÿซถ Without it, those forwarded packets look like they're coming from the guest's public address instead.
  • --userns spec โ€” the target user namespace to join, given as a path. If you hand over a PID and don't use this option, the user namespace is just the one belonging to that corresponding process ๐Ÿ’œ
  • --netns spec โ€” the target network namespace to join, as a path or a name. A name is treated the same way ip-netns(8) treats it, i.e. as equivalent to a path in /run/netns ๐ŸŒธ
This option can't be specified together with a PID. One or the other, bestie ๐Ÿ’…
  • --netns-only โ€” join only a target network namespace, not a user namespace, and don't create one for sandboxing purposes either. It's implied anyway if PATH or NAME are given without --userns โœจ
  • --no-netns-quit โ€” do not exit once the target namespace reference gets removed ๐Ÿ˜ณ

Without this option, pasta will terminate if the target network namespace is bound to the filesystem and the given path gets deleted โ€” or if the target network namespace is represented by a procfs entry and that entry is deleted, which basically represents the fact that a process with the given PID terminated ๐Ÿ’€

  • --config-net โ€” configure networking in the namespace: set up addresses and routes as configured or sourced from the host, and bring up the tap interface ๐Ÿ”ฅ
  • --no-copy-routes (DEPRECATED) โ€” with --config-net, do not copy all the routes associated to the interface we derive addresses and routes from: set up only the default gateway instead. It's implied by -g, --gateway, for the corresponding IP version only ๐Ÿ’…

Default is to copy all the routing entries from the interface in the outer namespace to the target namespace, translating the output interface attribute to the outbound interface in the namespace.

โš ๏ธ Okay so this configuration option is deprecated and will be removed in a future version. It is not expected to be of any use, and it simply reflects a legacy behaviour. If you have any use for this, refer to REPORTING BUGS below. Like, genuinely โ€” go tell them ๐Ÿ˜ญ
  • --no-copy-addrs (DEPRECATED) โ€” with --config-net, do not copy all the addresses associated to the interface we derive addresses and routes from: set up a single one. Implied by -a, --address, for the corresponding IP version only ๐ŸŒธ

Default is to copy all the addresses, except for link-local ones, from the interface in the outer namespace to the target namespace.

โš ๏ธ Same deal, bestie: this configuration option is deprecated and will be removed in a future version. It is not expected to be of any use, and it simply reflects a legacy behaviour. If you have any use for this, refer to REPORTING BUGS below ๐Ÿ™ˆ
  • --ns-mac-addr addr โ€” set the MAC address addr on the tap interface in the namespace ๐ŸŽ€

Default is to let the tap driver build a pseudorandom hardware address.

  • --no-splice โ€” disables the bypass path for inbound, local traffic ๐Ÿฆ‹ See the section Handling of local traffic in pasta in the NOTES for all the details.

โœจ EXAMPLES โœจ

okay bestie, buckle up ๐Ÿซถ this is the part where it stops being theory and starts being a whole terminal transcript. everything below is literal output, so don't retype it, just vibe with the flow ๐Ÿ˜Œ


๐Ÿ pasta

Create and use a new, connected, user and network namespace

so first you kick off an iperf3 server in the background with iperf3 -s -D, then run ./pasta โ€” and it immediately tells you everything it set up: the outbound interface, the namespace interface, ARP, DHCP, and NDP/DHCPv6 ๐Ÿ’…

$ iperf3 -s -D
$ ./pasta
Outbound interface: eth0, namespace interface: eth0
ARP:
    address: 28:16:ad:39:a9:ea
DHCP:
    assign: 192.168.1.118
    mask: 255.255.255.0
    router: 192.168.1.1
NDP/DHCPv6:
    assign: 2a02:6d40:3ca5:2001:b81d:fa4a:8cdd:cf17
    router: fe80::62e3:27ff:fe33:2b01
#
# dhclient -4 --no-pid
# dhclient -6 --no-pid
# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether 5e:90:02:eb:b0:2a brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.118/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2a02:6d40:3ca5:2001:b81d:fa4a:8cdd:cf17/128 scope global
       valid_lft forever preferred_lft forever
    inet6 2a02:6d40:3ca5:2001:5c90:2ff:feeb:b02a/64 scope global dynamic mngtmpaddr
       valid_lft 3591sec preferred_lft 3591sec
    inet6 fe80::5c90:2ff:feeb:b02a/64 scope link
       valid_lft forever preferred_lft forever
# ip route show
default via 192.168.1.1 dev eth0
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.118
# ip -6 route show
2a02:6d40:3ca5:2001:b81d:fa4a:8cdd:cf17 dev eth0 proto kernel metric 256 pref medium
2a02:6d40:3ca5:2001::/64 dev eth0 proto kernel metric 256 expires 3584sec pref medium
fe80::/64 dev eth0 proto kernel metric 256 pref medium
default via fe80::62e3:27ff:fe33:2b01 dev eth0 proto ra metric 1024 expires 3584sec pref medium
# iperf3 -c 127.0.0.1 -t1
Connecting to host 127.0.0.1, port 5201
[  5] local 127.0.0.1 port 51938 connected to 127.0.0.1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  4.46 GBytes  38.3 Gbits/sec    0   3.93 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-1.00   sec  4.46 GBytes  38.3 Gbits/sec    0             sender
[  5]   0.00-1.41   sec  4.45 GBytes  27.1 Gbits/sec                  receiver

iperf Done.
# iperf3 -c ::1 -t1
Connecting to host ::1, port 5201
[  5] local ::1 port 50108 connected to ::1 port 5201
[ ID] Interval           Transfer     Bitrate         Retr  Cwnd
[  5]   0.00-1.00   sec  4.35 GBytes  37.4 Gbits/sec    0   4.99 MBytes
- - - - - - - - - - - - - - - - - - - - - - - - -
[ ID] Interval           Transfer     Bitrate         Retr
[  5]   0.00-1.00   sec  4.35 GBytes  37.4 Gbits/sec    0             sender
[  5]   0.00-1.41   sec  4.35 GBytes  26.4 Gbits/sec                  receiver

iperf Done.
# ping -c1 -4 spaghetti.pizza
PING spaghetti.pizza (172.67.192.217) 56(84) bytes of data.
64 bytes from 172.67.192.217: icmp_seq=1 ttl=255 time=37.3 ms

--- spaghetti.pizza ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
# ping -c1 -6 spaghetti.pizza
PING spaghetti.pizza(2606:4700:3034::6815:147a (2606:4700:3034::6815:147a)) 56 data bytes
64 bytes from 2606:4700:3034::6815:147a: icmp_seq=1 ttl=255 time=35.6 ms

--- spaghetti.pizza ping statistics ---
1 packets transmitted, 1 received, 0% packet loss, time 0ms
rtt min/avg/max/mdev = 35.605/35.605/35.605/0.000 ms
# logout
$

like, look at those bitrates ๐Ÿ‘‘ 38.3 Gbits/sec over 127.0.0.1 and 37.4 Gbits/sec over ::1, both with 0 retransmits, and then ping -c1 -4 spaghetti.pizza and ping -c1 -6 spaghetti.pizza both come back with 0% packet loss. and yes you literally logout at the end, slay ๐Ÿ’…

heads up: notice it says both Outbound interface: eth0, namespace interface: eth0 here โ€” with pasta you get the namespace interface in that line too. keep that in mind for later, iykyk ๐Ÿ‘€

Connect an existing user and network namespace

same energy, except the namespace already exists โ€” you make one with unshare -rUn, grab the PID via echo $$, and then from another terminal you hand that PID to ./pasta 2446678 ๐ŸŽ€

$ unshare -rUn
# echo $$
2446678

     [From another terminal]
$ ./pasta 2446678
Outbound interface: eth0, namespace interface: eth0
ARP:
    address: 28:16:ad:39:a9:ea
DHCP:
    assign: 192.168.1.118
    mask: 255.255.255.0
    router: 192.168.1.1
NDP/DHCPv6:
    assign: 2a02:6d40:3ca5:2001:b81d:fa4a:8cdd:cf17
    router: fe80::62e3:27ff:fe33:2b01

     [Back to the original terminal]
# dhclient -4 --no-pid
# dhclient -6 --no-pid
# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: eth0: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 qdisc pfifo_fast state UNKNOWN group default qlen 1000
    link/ether fa:c1:2a:27:92:a9 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.118/24 brd 192.168.1.255 scope global eth0
       valid_lft forever preferred_lft forever
    inet6 2a02:6d40:3ca5:2001:b81d:fa4a:8cdd:cf17/128 scope global
       valid_lft forever preferred_lft forever
    inet6 2a02:6d40:3ca5:2001:f8c1:2aff:fe27:92a9/64 scope global dynamic mngtmpaddr
       valid_lft 3594sec preferred_lft 3594sec
    inet6 fe80::f8c1:2aff:fe27:92a9/64 scope link
       valid_lft forever preferred_lft forever

the way you have to hop terminals three times ๐Ÿ˜ญ but it's fine, it's giving multitasking main character energy ๐Ÿฆ‹


passt

Start and connect a guest with basic port forwarding

okay so here's the full guest setup โ€” ./passt -f -t 2222:22 starts it in the foreground with port forwarding, and it prints the ARP/DHCP/NDP info (with search: redhat.com under both DHCP and NDP/DHCPv6 this time โœจ), then tells you where the UNIX domain socket landed and gives you the two ways to start a guest ๐ŸŽ€

$ ./passt -f -t 2222:22
Outbound interface: eth0
ARP:
    address: 28:16:ad:39:a9:ea
DHCP:
    assign: 192.168.1.118
    mask: 255.255.255.0
    router: 192.168.1.1
        search:
            redhat.com
NDP/DHCPv6:
    assign: 2a02:6d40:3ca5:2001:b81d:fa4a:8cdd:cf17
    router: fe80::62e3:27ff:fe33:2b01
        search:
            redhat.com
UNIX domain socket bound at /tmp/passt_1.socket

You can now start qrap:
    ./qrap 5 qemu-system-x86_64 ... -net socket,fd=5 -net nic,model=virtio
or directly qemu, patched with:
    qemu/0001-net-Allow-also-UNIX-domain-sockets-to-be-used-as-net.patch
as follows:
    qemu-system-x86_64 ... -net socket,connect=/tmp/passt_1.socket -net nic,model=virtio

     [From another terminal]
$ ./qrap 5 qemu-system-x86_64 test.qcow2 -m 1024 -display none -nodefaults -nographic -net socket,fd=5 -net nic,model=virtio
Connected to /tmp/passt_1.socket

     [Back to the original terminal]
passt: DHCP: ack to request
passt:     from 52:54:00:12:34:56
passt: NDP: received NS, sending NA
passt: NDP: received RS, sending RA
passt: DHCPv6: received SOLICIT, sending ADVERTISE
passt: NDP: received NS, sending NA
passt: DHCPv6: received REQUEST/RENEW/CONFIRM, sending REPLY
passt: NDP: received NS, sending NA

     [From yet another terminal]
$ ssh -p 2222 root@localhost
root@localhost's password:
     [...]
# ip address show
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
    link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
    inet 127.0.0.1/8 scope host lo
       valid_lft forever preferred_lft forever
    inet6 ::1/128 scope host
       valid_lft forever preferred_lft forever
2: ens2: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 65520 qdisc pfifo_fast state UP group default qlen 1000
    link/ether 52:54:00:12:34:56 brd ff:ff:ff:ff:ff:ff
    inet 192.168.1.118/24 brd 192.168.1.255 scope global noprefixroute ens2
       valid_lft forever preferred_lft forever
    inet6 2a02:6d40:3ca5:2001:b81d:fa4a:8cdd:cf17/128 scope global noprefixroute
       valid_lft forever preferred_lft forever
    inet6 2a02:6d40:3ca5:2001:b019:9ae2:a2fe:e6b4/64 scope global dynamic noprefixroute
       valid_lft 3588sec preferred_lft 3588sec
    inet6 fe80::1f98:d09f:9309:9e77/64 scope link noprefixroute
       valid_lft forever preferred_lft forever

a few things bestie, because these details matter ๐Ÿ’–

  • this one says just Outbound interface: eth0 โ€” no namespace interface bit, that's a pasta thing ๐Ÿซถ
  • the socket is UNIX domain socket bound at /tmp/passt_1.socket, and both qrap and the patched qemu route through it โ€” -net socket,fd=5 for the qrap route (via ./qrap 5 ...), -net socket,connect=/tmp/passt_1.socket for the patched-qemu route ๐Ÿ”ฅ
  • the DHCP/NDP/DHCPv6 chatter with passt: prefixes is passt narrating the handshake while the guest boots: DHCP: ack to request / from 52:54:00:12:34:56, NDP: received NS, sending NA, NDP: received RS, sending RA, DHCPv6: received SOLICIT, sending ADVERTISE, DHCPv6: received REQUEST/RENEW/CONFIRM, sending REPLY ๐Ÿ‘‘
  • the guest's interface is called ens2 (not eth0!) and its addresses are noprefixroute, so like, don't panic when the name changes ๐Ÿ’€
  • and the whole thing is reachable because you forwarded 2222:22 โ€” hence ssh -p 2222 root@localhost ๐ŸŽ€

it literally just works, no cap ๐ŸŒˆ

โœจ NOTES โœจ

๐ŸŒ€ Handling of traffic with loopback destination and source addresses

So both passt and pasta can totally bind on ports with a loopback address (127.0.0.0/8 or ::1), depending on how you've configured things. But bestie, listen โ€” loopback destination or source addresses have to be changed before packets get delivered to the guest or target namespace. Why? Because most operating systems would straight-up drop packets received with loopback addresses on non-loopback interfaces ๐Ÿ˜ญ and also, it would be literally impossible for the guest or target namespace to route answers back.

For convenience, the source address on these packets gets translated to the address you specify with the --map-host-loopback option (with some exceptions in pasta mode, see the next section below ๐Ÿ‘€). If you don't specify it, it defaults โ€” somewhat arbitrarily, ngl โ€” to the address of the default IPv4 or IPv6 gateway (if any). And that's a known existing, valid address on the same subnet, so likeโ€ฆ it works.

If --no-map-gw or --map-host-loopback none are specified, this translation is disabled and packets with loopback addresses are just dropped. ๐Ÿซ 

Loopback destination addresses get translated to the observed external address of the guest or target namespace. For IPv6, the observed link-local address is used if the translated source address is link-local โ€” otherwise the observed global address is used. For both IPv4 and IPv6, if no addresses have been seen yet, the configured addresses will be used instead.

Example time, because yes ๐Ÿ’…: if passt or pasta receive a connection from 127.0.0.1, with destination 127.0.0.10, and the default IPv4 gateway is 192.0.2.1, while the last observed source address from guest or namespace is 192.0.2.2, this will be translated to a connection from 192.0.2.1 to 192.0.2.2. Slay.

Similarly, for traffic coming from guest or namespace, packets with a destination address corresponding to the --map-host-loopback address will have their destination address translated to a loopback address.

As an exception ๐Ÿšจ, traffic identified as DNS, originally directed to the --map-host-loopback address, if this address matches a resolver address on the host, is not translated to loopback โ€” it's handled in the same way as if specified as --dns-forward address, if no such option was given. In the common case where the host gateway also acts as a resolver, this avoids the host mapping shadowing the gateway/resolver itself. Iconic, honestly.

๐Ÿง Handling of local traffic in pasta

Depending on the configuration, pasta can bind to local ports in the init namespace, in the target namespace, or both โ€” and forward connections and packets to corresponding ports in the other namespace. Versatile queen ๐Ÿ‘‘

To avoid unnecessary overhead, these connections and packets are not forwarded through the tap device connecting the namespaces. Instead, pasta creates a socket in the destination namespace, with matching Layer-4 protocol, and uses it to forward local data. For TCP, data is forwarded between the originating socket and the new socket using the splice(2) system call โ€” and for UDP, a pair of recvmmsg(2) and sendmmsg(2) system calls deals with packet transfers. Efficient much? ๐Ÿ”ฅ

Because it's not possible to bind sockets to foreign addresses, this bypass only applies to local connections and traffic. It also means the address translation differs slightly from passt mode. Connections from loopback to loopback on the host will appear to come from the target namespace's public address within the guest, unless --host-lo-to-ns-lo is specified โ€” in which case they'll appear to come from loopback in the namespace as well. That latter behaviour used to be the default, but it's usually undesirable, since it can unintentionally expose namespace local services to the host. Yeahโ€ฆ we don't want that ๐Ÿซฃ

๐Ÿ”’ Binding to low numbered ports (well-known or system ports, up to 1023)

If your port forwarding configuration requires binding to ports with numbers lower than 1024, passt and pasta will try to bind to them, but will fail, unless either:

  • the sys.net.ipv4.ip_unprivileged_port_start sysctl is set to the number of the lowest port passt and pasta need. For example, as root:
sysctl -w net.ipv4.ip_unprivileged_port_start=443
Note: this is the recommended way of enabling passt and pasta to bind to ports with numbers below 1024. โœจ

This is, in general, not the recommended way, because passt and pasta might be used as a vector to effectively use this capability from another process. ๐Ÿ˜ฌ

However, if your environment is sufficiently controlled by an LSM (Linux Security Module) such as AppArmor, SELinux, Smack or TOMOYO, and no other processes can interact in such a way in virtue of this, granting this capability to passt and pasta only can effectively prevent other processes from utilising it.

Note that this will not work for automatic detection and forwarding of ports with pasta, because pasta will relinquish this capability at runtime.

To grant this capability, you can issue, as root:

for p in $(which passt passt.avx2); do
     setcap 'cap_net_bind_service=+ep' "${p}"
done

๐Ÿ“ ICMP/ICMPv6 Echo sockets

ICMP and ICMPv6 Echo requests coming from guest or target namespace are handled using so-called "ping" sockets, introduced in Linux 2.6.30. To preserve the original identifier (see RFC 792, page 14, for ICMP, and RFC 4443, section 4.1, for ICMPv6), passt and pasta try to bind these sockets using the observed source identifier as "port" โ€” that corresponds to Echo identifiers for "ping" sockets. Keeping it faithful, love that for us ๐Ÿซถ

As bind(2) failures were seen with particularly restrictive SELinux policies, a fall-back mechanism maps different identifiers to different sockets, and identifiers in replies will be mapped back to the original identifier of the request. However, if bind(2) fails and the fall-back mechanism is used, echo requests will be forwarded with different, albeit unique, identifiers. Not ideal but it's giving resourceful ๐Ÿ’€

For ICMP and ICMPv6 Echo requests to work, the ping_group_range parameter needs to include the PID of passt or pasta, see icmp(7).

๐Ÿฆ‹ pasta and loopback interface

As pasta connects to an existing namespace, or once it creates a new namespace, it will also ensure that the loopback interface, lo, is brought up. This is needed to bind ports using the loopback address in the namespace. Little housekeeping moment ๐Ÿงน

๐Ÿ“ˆ TCP sending window and TCP_INFO before Linux 5.3

To synchronise the TCP sending window from host Layer-4 sockets to the TCP parameters announced in TCP segments sent over the Layer-2 interface, passt and pasta routinely query the size of the sending window seen by the kernel on the corresponding socket using the TCP_INFO socket option, see tcp(7). Before Linux 5.3, i.e. before Linux kernel commit 8f7baad7f035 ("tcp: Add snd_wnd to TCP_INFO"), the sending window (snd_wnd field) is not available.

If the sending window cannot be queried, it will always be announced as the current sending buffer size to guest or target namespace. This might affect throughput of TCP connections. F in the chat for your throughput ๐Ÿ˜ญ

๐ŸŒˆ Local mode for disconnected setups

If passt and pasta fail to find a host interface with a configured address, other than loopback addresses, they will, obviously, not attempt to source addresses or routes from the host. Like, there's nothing to source from, bestie.

In this case, unless configured otherwise, they will assign the IPv4 link-local address 169.254.2.1 to the guest or target namespace, and no IPv6 address. The notion of the guest or target namespace IPv6 address is derived from the first link-local address observed.

Default gateways will be assigned as the link-local address 169.254.2.2 for IPv4, and as the link-local address fe80::1 for IPv6. Off-grid but make it functional โœจ


๐Ÿ’€ LIMITATIONS ๐Ÿ’€

Currently, IGMP/MLD proxying (RFC 4605) and support for SCTP (RFC 4960) are not implemented.

TCP Selective Acknowledgment (RFC 2018), as well as Protection Against Wrapped Sequences (PAWS) and Round-Trip Time Measurement (RTTM), both described by RFC 7232, are currently not implemented. So don't come for them, they're not there yet ๐Ÿ™ˆ


๐Ÿ‘‘ AUTHORS ๐Ÿ‘‘

Stefano Brivio <sbrivio@redhat.com>, David Gibson <david@gibson.dropbear.id.au>. Legends, fr fr ๐Ÿ’–


๐Ÿ› REPORTING BUGS ๐Ÿ›

Please report issues on the bug tracker at https://passt.top/passt/bugs, or send a message to the passt-user@passt.top mailing list, see https://passt.top/passt/lists. They wanna hear from you ๐Ÿซถ


Copyright (c) 2020-2022 Red Hat GmbH.

passt and pasta are free software: you can redistribute them and/or modify them under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. Free as in freedom, periodt ๐ŸŒˆ


๐ŸŒธ SEE ALSO ๐ŸŒธ

namespaces(7), qemu(1), qrap(1), slirp4netns(1).

High-level documentation is available at https://passt.top/passt/about/. Go read it, iykyk ๐Ÿ’…


And that's the whole thing, bestie โ€” this is the passt(1) manual page talking, footer and all, dated and versioned right there at the bottom like a little signature. Go forth and forward some packets, you've got this ๐Ÿ‘‘๐ŸŽ€๐Ÿฆ‹

๐Ÿ“ฆ where this page comes from