NetworkPolicy presets
Static methods that return pre-configured policies.NetworkPolicy::allow_all()
NetworkPolicy::none()
exec and fs still work since they use the host-guest channel, not the network.
NetworkPolicy::public_only()
10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16, 127.0.0.0/8, 169.254.0.0/16) and cloud metadata endpoints. Allow everything else. This is the default policy.
NetworkBuilder
Builder for configuring the sandbox’s network stack. Used inSandboxBuilder::network(|n| n...).
block_domain()
| Name | Type | Description |
|---|---|---|
| domain | impl Into<String> | Domain to block (e.g. "malware.example.com") |
block_domain_suffix()
.tracking.com blocks a.tracking.com, b.c.tracking.com, etc.
Parameters
| Name | Type | Description |
|---|---|---|
| suffix | impl Into<String> | Domain suffix (e.g. ".tracking.com") |
dns_rebind_protection()
true.
Parameters
| Name | Type | Description |
|---|---|---|
| enabled | bool | Enable or disable |
max_connections()
| Name | Type | Description |
|---|---|---|
| max | usize | Maximum concurrent connections |
on_secret_violation()
| Name | Type | Description |
|---|---|---|
| action | ViolationAction | Response to a violation |
policy()
public_only policy.
Parameters
| Name | Type | Description |
|---|---|---|
| policy | NetworkPolicy | Network access policy |
tls()
TlsBuilder for setting bypass domains, intercepted ports, CA certificates, and upstream verification.
Parameters
| Name | Type | Description |
|---|---|---|
| f | TlsBuilder | Configure TLS interception. |
TlsBuilder
Builder for TLS interception settings. Used inNetworkBuilder::tls(|t| t...).
block_quic()
true.
Parameters
| Name | Type | Description |
|---|---|---|
| block | bool | Enable or disable |
bypass()
*.suffix wildcards. Use for domains that use certificate pinning.
Parameters
| Name | Type | Description |
|---|---|---|
| pattern | impl Into<String> | Domain or wildcard (e.g. "*.pinned-api.com") |
intercept_ca_cert()
| Name | Type | Description |
|---|---|---|
| path | impl Into<PathBuf> | Path to PEM-encoded CA certificate |
intercept_ca_key()
| Name | Type | Description |
|---|---|---|
| path | impl Into<PathBuf> | Path to PEM-encoded CA private key |
intercepted_ports()
[443]. Add additional ports if services use non-standard HTTPS ports.
Parameters
| Name | Type | Description |
|---|---|---|
| ports | Vec<u16> | List of TCP ports |
upstream_ca_cert()
| Name | Type | Description |
|---|---|---|
| path | impl Into<PathBuf> | Path to PEM-encoded CA certificate |
verify_upstream()
true, connections to servers with invalid or self-signed certificates are rejected. When false, all server certificates are accepted. Default: true.
Parameters
| Name | Type | Description |
|---|---|---|
| verify | bool | Enable or disable |
Types
Action
| Value | Description |
|---|---|
Allow | Permit the traffic |
Deny | Drop the traffic silently |
Destination
| Variant | Description |
|---|---|
Any | Match any address |
Cidr(IpNetwork) | Match a CIDR range (e.g. 10.0.0.0/8) |
Domain(String) | Match an exact domain |
DomainSuffix(String) | Match a domain suffix |
Group(DestinationGroup) | Match a predefined address group |
DestinationGroup
| Value | Description |
|---|---|
LinkLocal | 169.254.0.0/16, fe80::/10 |
Loopback | 127.0.0.0/8, ::1 |
Metadata | Cloud metadata endpoints (169.254.169.254) |
Multicast | 224.0.0.0/4, ff00::/8 |
Private | 10.0.0.0/8, 172.16.0.0/12, 192.168.0.0/16 |
Direction
| Value | Description |
|---|---|
Inbound | Traffic entering the sandbox (via published ports) |
Outbound | Traffic leaving the sandbox |
NetworkPolicy
A network access policy consisting of a default action and an ordered list of rules evaluated first-match-wins.PortRange
| Method | Description |
|---|---|
PortRange::range(start, end) | Match a range of ports (inclusive) |
PortRange::single(port) | Match a single port |
Protocol
| Value | Description |
|---|---|
Icmpv4 | ICMPv4 traffic |
Icmpv6 | ICMPv6 traffic |
Tcp | TCP traffic |
Udp | UDP traffic |
Rule
A single network policy rule.| Field | Type | Description |
|---|---|---|
| action | Action | What to do when this rule matches |
| destination | Destination | Target address filter |
| direction | Direction | Traffic direction |
| ports | Option<PortRange> | Port filter (None matches all) |
| protocol | Option<Protocol> | Protocol filter (None matches all) |
| Method | Description |
|---|---|
Rule::allow_outbound(destination) | Create an outbound allow rule |
Rule::deny_outbound(destination) | Create an outbound deny rule |
ViolationAction
Action taken when a secret placeholder is sent to a disallowed host.| Value | Description |
|---|---|
Block | Silently drop the request. The guest sees a connection reset. This is the default. |
BlockAndLog | Drop the request and emit a warning log on the host side. |
BlockAndTerminate | Drop the request, log an error, and shut down the entire sandbox. |