Appearance
Sandbox Network Access
Sandboxes have internet access enabled by default, allowing HTTP requests, file downloads, API calls, and more. Flexible network configuration options are also available.
Basic Network Access Control
Enable/Disable Internet Access
Use the allowInternetAccess parameter to quickly enable or disable all internet access.
javascript
import { Sandbox } from '@e2b/code-interpreter'
async function main() {
// Enable internet access (default)
const sandbox = await Sandbox.create({ allowInternetAccess: true })
await sandbox.kill()
// Disable internet access
const isolatedSandbox = await Sandbox.create({ allowInternetAccess: false })
await isolatedSandbox.kill()
}
main()Fine-Grained Network Rules
Configuration
For more precise network control, use the network parameter to configure fine-grained rules. Note: When using the network parameter, the allowInternetAccess parameter is ignored.
IP and CIDR Filtering
javascript
import { Sandbox, ALL_TRAFFIC } from '@e2b/code-interpreter'
async function main() {
// Allow only specific IPs
const sandbox = await Sandbox.create({
network: {
denyOut: [ALL_TRAFFIC],
allowOut: ['1.1.1.1', '8.8.8.0/24']
}
})
await sandbox.kill()
}
main()
### Domain Filtering
```javascript
import { Sandbox, ALL_TRAFFIC } from '@e2b/code-interpreter'
async function main() {
const sandbox = await Sandbox.create({
network: {
allowOut: ['api.example.com', '*.github.com'],
denyOut: [ALL_TRAFFIC]
}
})
await sandbox.kill()
}
main()