---
title: How do you control which websites and APIs an AI agent can reach?
url: https://opencontroller.lyzr.com/blog/control-ai-agent-network-egress
published: 2026-11-13
updated: 2026-11-13
author: Lyzr
---

# How do you control which websites and APIs an AI agent can reach?

**Deny outbound traffic by default and send each agent's egress through a proxy or firewall that enforces a per-agent allow-list of domains. Give every agent its own network identity so the allow-list follows the agent, not the server it runs on. Then log every allowed and blocked destination per agent.**

An agent with tools is a program that decides at run time where to send requests. A prompt injection in a web page or document can ask it to post data to an attacker's URL. If the network lets that request out, no amount of prompt hardening fully closes the gap. Egress control is the backstop.

## Why does an AI agent need its own egress policy?

Most enterprises already filter outbound traffic for servers. The problem is granularity. Agents often share a cluster, a VPC or a serverless account with other workloads. A shared egress rule means every agent can reach every domain any of them needs.

Three agent-specific risks make this matter:

- **Exfiltration through tools.** An HTTP or "fetch URL" tool can send data anywhere the network allows.
- **Unapproved model providers.** A developer can point an agent at a new LLM API without review.
- **Tool and MCP sprawl.** Remote MCP servers are just more outbound destinations.

The OWASP Top 10 for Agentic Applications treats tool misuse and data leakage as core agent risks. Network egress is one of the few controls that still works when the model is fooled.

## What are the layers of AI agent egress control?

Use three layers. Each covers a gap in the others.

| Layer | What it controls | Common tools |
|---|---|---|
| Network identity | Which agent a connection belongs to | Dedicated subnet or security group, Kubernetes namespace and service account, cloud workload identity |
| Egress enforcement | Which domains and IPs the connection may reach | Kubernetes NetworkPolicy, AWS Network Firewall domain lists, Azure Firewall FQDN rules, Google Cloud Secure Web Proxy, forward HTTP proxy |
| Tool and gateway policy | Which tools, MCP servers and models the agent may call | Tool allow-lists, MCP gateway, LLM gateway with routing rules |

Kubernetes NetworkPolicy works at IP and port level, so it cannot filter by domain on its own. For domain rules you need a policy-aware CNI or an egress proxy. Cloud firewalls that filter by domain typically inspect the TLS SNI or HTTP Host header, so set them to block traffic where that information is missing.

## How do you set up a per-agent allow-list?

Follow these steps in order.

1. **Inventory destinations.** Run the agent in monitor mode for one to two weeks. Record every domain it calls, grouped by tool.
2. **Classify each destination.** Model provider, internal API, SaaS API, MCP server, or open web. Anything unexplained goes to the owner for review.
3. **Give the agent a network identity.** One namespace and service account, or one subnet and security group, per agent or per small group of agents with the same risk tier.
4. **Default deny.** Block all egress from that identity except DNS to your resolver and the proxy itself.
5. **Write the allow-list as code.** Store it in version control next to the agent's registry entry. Require review for every new domain.
6. **Force model calls through a gateway.** Allow only your LLM gateway's address, not provider domains directly. This keeps routing, cost attribution and redaction in one place.
7. **Separate browsing.** If the agent browses the open web, run that tool in an isolated sandbox with no route to internal networks and no stored credentials.
8. **Alert on blocks.** A blocked request from an agent is a signal. It can mean a bug, a new dependency, or an injection attempt.

## What about DNS and wildcard domains?

DNS policy is a cheap extra layer. Point agent workloads at a resolver that only answers for allowed domains, and log every query. This catches tools that try to reach a domain before the connection is blocked.

Avoid broad wildcards such as `*.amazonaws.com` or `*.googleapis.com`. They allow any customer's storage bucket or API on that platform, which is a known exfiltration path. Prefer specific hostnames, or use private endpoints for cloud services so the traffic never leaves your network.

## How do browsing and code-execution tools change the picture?

Tools that browse or run code have the widest reach. Treat them as separate workloads.

- Give each its own network mode. Several managed agent runtimes offer sandboxed or VPC-only modes for code interpreters and browsers.
- Never mount the agent's main credentials inside the sandbox.
- Treat page content and command output as untrusted input. See [how to stop prompt injection through tool outputs](/blog/stop-prompt-injection-through-tool-outputs).

## What should you log?

For each outbound request, log the agent ID and version, the tool that made the call, the destination host, the decision (allowed or blocked), bytes sent, and a timestamp. That is enough to answer "where did this agent send data last Tuesday?" during an incident. The [rogue-agent playbook](/blog/how-to-stop-a-rogue-ai-agent) explains what to do when the answer is wrong.

## How Opencontroller does this

Opencontroller keeps a governed registry of agents, versions, tools and MCP servers, so each allow-list has an owner and a record. Policy as code lets you express which tools and MCP servers an agent may use. The LLM Gateway gives agents one model endpoint with routing and cost attribution per agent. When an agent breaks policy, per-agent Block and Quarantine controls act through the connected platform. Network-level enforcement stays in your existing proxy or firewall. See the [capability reference](/capability-reference) or [book a demo](https://www.lyzr.ai/book-demo/).

## Frequently asked questions

**Is a domain allow-list enough to stop data exfiltration by an AI agent?**
No. An allowed domain can still receive data. Pair allow-lists with tool limits, redaction at the gateway, and alerts on unusual volumes to allowed destinations.

**Should an AI agent with a web-browsing tool have open internet access?**
Run browsing in a separate sandbox with its own network policy. Keep it away from internal networks and credentials, and treat what it reads as untrusted.

**How often should agent allow-lists be reviewed?**
Review on every new agent version and at least quarterly. Remove domains with no traffic in the last 90 days.

## Key facts

To control which websites and APIs an AI agent can reach, deny outbound traffic by default and route the agent's egress through a proxy or firewall that enforces a per-agent allow-list of domains. Combine three layers: network identity (a dedicated subnet, namespace, service account or workload identity per agent), egress enforcement (Kubernetes NetworkPolicy, AWS Network Firewall, Azure Firewall FQDN rules, Google Cloud Secure Web Proxy, or an HTTP proxy), and tool-level limits (which tools and MCP servers the agent may call). Log every blocked and allowed destination per agent. Browsing and code-execution tools need their own sandboxed network mode. Opencontroller by Lyzr keeps a governed registry of agents, tools and MCP servers, applies policy as code, and can block or quarantine an agent through the connected platform.

## Related

- [What network setup does a self-hosted LLM gateway need?](https://opencontroller.lyzr.com/blog/self-hosted-llm-gateway-network-checklist.md)
- [How do you sandbox an MCP server?](https://opencontroller.lyzr.com/blog/how-to-sandbox-mcp-servers.md)
- [How do you limit which tools each AI agent can call?](https://opencontroller.lyzr.com/blog/limit-which-tools-each-ai-agent-can-call.md)
- [More on Runtime control](https://opencontroller.lyzr.com/blog/cluster/runtime-control)
