Networking overview
A Workspace's network policyThe rules that decide where a Workspace's outbound traffic may go: its mode, destination rules, and any Egress or Resolver it references. A new Workspace has no network access by default. decides which external addresses it can reach and which path its traffic takes. This page introduces the parts of the policy and the paths, and walks through sending all of a Workspace's traffic out through your own exit.
Overview
The network policy has four parts:
| Part | Effect | In kibo |
|---|---|---|
| mode | DENY_ALL denies all outbound traffic; PUBLIC_INTERNET allows the internet | deny-all or public-internet, as the value of --network or the mode argument of network set |
| Destination rules | Narrow outbound internet traffic by destination address | --allow, --deny |
| EgressAn outbound SOCKS5 proxy that the caller runs. When a Workspace's network policy references it, TCP connections to the given ranges leave from the caller's network. | Send TCP to some destinations out through a SOCKS5 endpoint the caller runs | --egress, --egress-destination |
| ResolverA DNS server that the caller provides. When a Workspace's network policy references it, the guest's DNS queries go to it. | Forward the guest's DNS queries to an upstream the caller chooses | --resolver, --resolver-path |
- The default mode is
DENY_ALL. - The last three parts apply only to
PUBLIC_INTERNET. - You give the policy when you create the Workspace, with the flags of the same names on
kibo workspace create. - You can change the policy with
kibo workspace networkwhile the Workspace isAVAILABLEorSTOPPED. See Effect of a change.
Egresses and Resolvers are separate objects. Create them first, then reference them by ID in the policy. One Egress or Resolver can be referenced by many Workspaces.
Traffic paths
The diagram below shows one node and the three networks it connects to: the internet; the deployment network, meaning the deployer's management network and other private and special-purpose addresses; and the caller network, meaning the caller's SOCKS5 endpoint and internal network. Click "Next" below the diagram, or select the diagram and press the arrow keys, to add the three paths one by one.
| Path | When it is used | What it reaches | Details |
|---|---|---|---|
| Direct | Under PUBLIC_INTERNET, connections whose destination is outside the Egress ranges | The internet. Private and special-purpose addresses are refused | Network policy |
| Via Egress | New TCP connections whose destination is inside the Egress ranges referenced by the policy | Wherever the SOCKS5 endpoint can reach, including the caller's internal network | Egress |
| DNS query | Queries the guest sends to the link DNS address | The deployment DNS servers, or the Resolver referenced by the policy | DNS and Resolvers |
Under DENY_ALL, none of the three paths works: outbound connections are refused, and DNS queries fail immediately.
Use cases
| Need | Approach |
|---|---|
| Outbound connections leave from your own network, and destinations see your own exit address | Reference an Egress with ranges 0.0.0.0/0 and ::/0 |
| Reach services in your own internal network | Reference an Egress with your internal network's ranges |
Migrate from E2B, with code that already uses egressProxy | No code changes; the gateway creates the Egress. See Egress proxy |
| The addresses from the deployment DNS servers do not work, or CDN domains must resolve according to where your own exit is | Reference a Resolver with a path via Egress |
| Queries must not go through the deployer's DNS servers, or you want to use your own filtering DNS server | Reference a Resolver |
| Allow access to only a few addresses | Destination rules: deny with 0.0.0.0/0 and ::/0, allow with the allowed ranges |
Steps
The steps below send all outbound TCP and DNS queries of a Workspace out through the caller's own SOCKS5 endpoint. When the server does not support Egress or Resolver, kibo exits with 14 and sends no request.
-
Create an Egress, reading the password from a file.
--udplets theudpResolver in step 3 send queries through it:egress_id=$(kibo egress create --address proxy.example.com:1080 --username alice --password-file ./proxy-password --udp -q) -
Reference the Egress in the policy, with ranges covering all IPv4 and IPv6 destinations:
kibo workspace network set "$workspace_id" public-internet --egress "$egress_id" --egress-destination 0.0.0.0/0 --egress-destination ::/0 -
Create a Resolver and reference it with a path through this Egress, so that DNS queries also go out through it:
resolver_id=$(kibo resolver create --udp 10.0.0.53 -q) kibo workspace network add "$workspace_id" --resolver "$resolver_id" --resolver-path "egress:$egress_id" -
Show the Workspace to confirm the change is in effect:
kibo workspace get "$workspace_id"When the revision on the
Egress appliedline matches the one fromkibo egress get, new connections are going out through this Egress. If there is anEgress faultline, see Network troubleshooting.
With the API
Each part of the policy is a field of the network policy:
| Part | API field |
|---|---|
| mode | mode |
| Destination rules | allow, deny |
| Egress | egresses |
| Resolver | resolvers |
- Give the policy at creation in
WorkspaceCreateSpec.network_policy. - Change it with
UpdateWorkspaceNetworkPolicywhile the Workspace isAVAILABLEorSTOPPED. - Before using Egress or Resolver, check the capability names.
The steps above map to these calls:
- Create the Egress with
EgressService.CreateEgress. - In
UpdateWorkspaceNetworkPolicy, write one entry inegresseswithegress_idanddestinations, and one entry inresolverswithresolver_idandpath.egress_id. - Use
network_policy_statusfromGetWorkspaceto check whether the change is in effect.
Next steps
- Network policy: mode, destination rules, and how to change the policy and confirm it is in effect.
- Egress: send some connections out through the caller's own SOCKS5 endpoint.
- DNS and Resolvers: where the guest's DNS queries go, and how to switch to an upstream the caller chooses.
- Network troubleshooting: confirm the policy is in effect, and tell causes apart when an Egress or Resolver fails.
Desktop
A desktop Workspace runs a graphical desktop in the guest. You can view and operate it in a local browser, or script it with screenshots and keyboard and mouse input from kibo workspace desktop.
Network policy
The mode and destination rules of a network policy decide which addresses a Workspace can reach directly. This page shows how to change them with kibo, how a destination address is matched, and when a change takes effect.