Network
Frozen dataclass for sandbox network configuration. Use the class method presets for common cases, or construct directly with custom options.| Field | Type | Default | Description |
|---|---|---|---|
| policy | str | NetworkPolicy | None | None | Preset name or custom NetworkPolicy |
| ports | Mapping[int, int] | {} | Port mappings from host to guest |
| block_domains | tuple[str, ...] | () | Block DNS for exact domains (returns NXDOMAIN) |
| block_domain_suffixes | tuple[str, ...] | () | Block DNS for all subdomains of a suffix |
| dns_rebind_protection | bool | True | Block DNS responses resolving to private IPs |
| tls | TlsConfig | None | None | TLS interception configuration |
| max_connections | int | None | None | Maximum concurrent connections |
Network.none()
exec and fs still work since they use the host-guest channel, not the network.
Returns
| Type | Description |
|---|---|
Network | Fully airgapped network configuration |
Network.public_only()
| Type | Description |
|---|---|
Network | Public-only network configuration |
Network.allow_all()
| Type | Description |
|---|---|
Network | Unrestricted network configuration |
Types
NetworkPolicy
Frozen dataclass for a custom network policy with rules.Rule
Frozen dataclass for a single network policy rule.| Field | Type | Default | Description |
|---|---|---|---|
| action | Action | - | What to do when this rule matches |
| direction | Direction | Direction.EGRESS | Traffic direction |
| destination | str | None | None | Target filter: a DestGroup value, domain, CIDR range, domain suffix (prefixed with "."), or "*" for any |
| protocol | Protocol | None | None | Protocol filter |
| port | int | str | None | None | Single port (443) or range ("8000-9000") |
Rule.allow()
Returns
| Type | Description |
|---|---|
Rule | An allow rule |
Rule.deny()
Returns
| Type | Description |
|---|---|
Rule | A deny rule |
TlsConfig
Frozen dataclass for TLS interception settings withinNetwork.
| Field | Type | Default | Description |
|---|---|---|---|
| bypass | tuple[str, ...] | () | Domains to skip interception. Use for domains with certificate pinning. |
| verify_upstream | bool | True | Verify upstream server certificates. Set to False only for self-signed servers. |
| intercepted_ports | tuple[int, ...] | (443,) | TCP ports where TLS interception is active |
| block_quic | bool | False | Block QUIC/HTTP3 (UDP) on intercepted ports, forcing TCP/TLS fallback |
| ca_cert | str | None | None | Path to a custom interception CA certificate PEM file |
| ca_key | str | None | None | Path to a custom interception CA private key PEM file |
| ca_cn | str | None | None | Common name for the generated interception CA |
Action
String enum (StrEnum) for policy actions.
| Value | Description |
|---|---|
"allow" | Permit the traffic |
"deny" | Drop the traffic silently |
Direction
String enum for traffic direction.| Value | Description |
|---|---|
"egress" | Traffic leaving the sandbox |
"ingress" | Traffic entering the sandbox (via published ports) |
Protocol
String enum for network protocols in policy rules.| Value | Description |
|---|---|
"tcp" | TCP traffic |
"udp" | UDP traffic |
"icmpv4" | ICMPv4 traffic |
"icmpv6" | ICMPv6 traffic |
PortProtocol
String enum for port-level protocol selection.| Value | Description |
|---|---|
"tcp" | TCP port |
"udp" | UDP port |
DestGroup
String enum for well-known destination groups used inRule.destination.
| Value | Description |
|---|---|
"loopback" | Loopback addresses (127.0.0.0/8, ::1) |
"private" | Private/RFC 1918 addresses (10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16) |
"link-local" | Link-local addresses (169.254.0.0/16, fe80::/10) |
"metadata" | Cloud metadata endpoints (169.254.169.254) |
"multicast" | Multicast addresses (224.0.0.0/4, ff00::/8) |