Agent-Sim Proxy Setup on Linux: Routing and Exit-IP Checks
Dec 1, 2026 · Guides · 11 min read
Key takeaways: Configure Agent-Sim proxy routing with a Rola static residential endpoint, redsocks, and Linux firewall rules. Assign each independently routed simulator environment its own endpoint, then confirm the exit IP inside the simulator and target app. Manage website request rates and LLM token budgets separately so each workload stays within its service limits.
Agent-Sim provides a CLI and MCP server for controlling iOS simulators on x86-64 Linux through x86Sim. Agents can open apps, read screens, tap controls, and manage pools of phones.
Use a Rola static residential proxy when your Agent-Sim workflow needs a consistent public exit across repeated app checks or long-running signed-in sessions. Assigning a fixed exit to each simulator environment keeps IP rotation out of session troubleshooting and makes regional tests easier to repeat.
Start with an Agent-Sim installation that has completed setup and can boot a simulator, sudo access on an Ubuntu host using systemd, and a working SOCKS5 endpoint. Run the simulator workload under a dedicated, non-root Linux account.
Redsocks connects to the upstream proxy, while Linux firewall rules select the simulator traffic to route through it.
Choose the Correct Network Layer
The proxy must handle the connections made by the application you want to route.
| Layer | Scope | Limitation |
|---|---|---|
| Host environment variables | Programs that honor HTTP_PROXY or HTTPS_PROXY |
Setting them does not establish the route used by simulated iOS applications |
| iOS system HTTP proxy | Clients that follow the runtime’s system proxy settings | Requires an available configuration interface and app support; not a native SOCKS5 setting |
| Linux TCP forwarding | Connections selected by network rules | Requires the correct network path; DNS, UDP, QUIC, and IPv6 need separate consideration |
The Linux recipe below applies to IPv4 TCP connections originating locally under a dedicated Linux user. These connections pass through the host’s OUTPUT chain. Traffic forwarded from a bridged container or another network namespace needs configuration at its own egress point instead.
Get a Rola Static Residential Endpoint
Open Static Residential IP → Proxy list in your Rola dashboard. Select SOCKS5 for the forwarding recipe below and obtain the endpoint details:

Open Static Residential IP, select Proxy list, and choose socks5 for the endpoint.
Gateway:Port:Username:Password
Record the gateway, port, credentials, assigned location, and expiry. The gateway is the address your client connects to; the public exit seen by a destination may be different.
Copy the value under Gateway:Port:Username:Password for the selected row. Keep the four fields separate when entering them in the commands and configuration below.

Copy the selected endpoint’s connection string from the Proxy list.
Which authentication method should you use?
Use the username and password supplied with this static endpoint. Our API whitelist workflow provides password-free access for Rotating Residential, Rotating Datacenter, and Mobile IP: allowlist the connecting server’s public IP, extract IP:port endpoints through the API, and connect using those endpoints. Keep username/password authentication for the static endpoint in this guide.
Check endpoint connectivity
For basic residential proxy setup, confirm the endpoint address, port, and authentication before configuring simulator routing. Replace the placeholders and run:
curl --silent --show-error --fail \
--connect-timeout 10 --max-time 30 \
--proxy socks5h://PROXY_HOST:PROXY_PORT \
--proxy-user 'PROXY_USERNAME' \
https://api.ipify.org
Curl prompts for the password when only a username is supplied. Here, socks5h asks the proxy to resolve the destination hostname. Record the returned address for comparison with the simulator’s exit.
For an HTTP endpoint, the equivalent request is:
curl --silent --show-error --fail \
--connect-timeout 10 --max-time 30 \
--proxy http://PROXY_HOST:PROXY_PORT \
--proxy-user 'PROXY_USERNAME' \
https://api.ipify.org
When curl completes successfully and returns an IP address, save it for the simulator check. Resolve any endpoint errors using the troubleshooting table below before adding firewall rules.
Configure Linux TCP Forwarding
Use a dedicated Linux account for the simulator workload. The rule below selects that account’s outbound TCP connections, so unrelated applications should run under other accounts.
First identify the user that actually owns the simulator’s network sockets. A launcher account is not necessarily the socket owner when a service makes connections on its behalf. Inspect active sockets and processes with:
sudo ss -ntp
# Replace PID with the process ID shown for the relevant connection.
ps -o user=,uid=,pid=,args= -p PID
The iptables owner match selects locally generated traffic by socket owner. Use the account observed above as SIM_USER. If a container or separate network namespace owns the connections, configure routing at that environment’s egress instead of attaching this rule to the host’s OUTPUT chain.
Step 1: Install redsocks
On Ubuntu:
sudo apt update
sudo apt install redsocks iptables curl
Redsocks receives redirected TCP connections and opens connections through an upstream proxy. It runs separately from Agent-Sim.
Step 2: Configure the upstream endpoint
Preserve the existing configuration if this machine already uses redsocks. On a dedicated deployment, edit:
sudoedit /etc/redsocks.conf
Use this configuration with your own endpoint values. The gateway must be a numeric IPv4 address; resolve a hostname with getent ahostsv4 PROXY_HOST if needed.
base {
log_debug = off;
log_info = on;
log = "syslog:daemon";
daemon = on;
redirector = iptables;
}
redsocks {
local_ip = 127.0.0.1;
local_port = 12345;
ip = PROXY_GATEWAY_IPV4;
port = PROXY_PORT;
type = socks5;
login = "PROXY_USERNAME";
password = "PROXY_PASSWORD";
}
Gateway and port values are unquoted; credentials are quoted strings. Escape embedded quote and backslash characters according to your installed redsocks configuration syntax. Keep the login and password entries for the static endpoint used here.

Configure the local listener and SOCKS5 upstream in /etc/redsocks.conf.
Keep the file readable only by root and, if required, the service account. On an installation where the service reads the configuration as root:
sudo chmod 600 /etc/redsocks.conf
sudo redsocks -t -c /etc/redsocks.conf && sudo systemctl restart redsocks
sudo systemctl status redsocks --no-pager
sudo ss -lntp 'sport = :12345'
Continue only after the configuration check succeeds, the service is active, and ss shows a listener on 127.0.0.1:12345. If the service cannot read its configuration, set file ownership and permissions for its actual service account while keeping credentials private. Keep the listener bound to loopback.
Step 3: Route the selected user’s TCP connections
Save the following as agent-sim-route.sh. Replace the username with the socket-owning account and the gateway with the same numeric IPv4 address used in redsocks.
The script checks the user, gateway, listener, and chain name before creating rules. If setup fails, it removes the chain it created. An existing AGENT_SIM_TCP chain causes it to stop without changing that chain.
#!/usr/bin/env bash
set -Eeuo pipefail
SIM_USER='YOUR_SIMULATOR_LINUX_USER'
PROXY_IPV4='YOUR_PROXY_GATEWAY_IPV4'
CHAIN='AGENT_SIM_TCP'
if (( EUID != 0 )); then
echo 'Run this script with sudo.' >&2
exit 1
fi
SIM_UID=$(id -u "$SIM_USER")
if (( SIM_UID == 0 )); then
echo 'Select a dedicated non-root simulator account.' >&2
exit 1
fi
if [[ ! "$PROXY_IPV4" =~ ^([0-9]{1,3}\.){3}[0-9]{1,3}$ ]]; then
echo 'Enter a numeric IPv4 gateway address.' >&2
exit 1
fi
IFS=. read -r -a octets <<< "$PROXY_IPV4"
for octet in "${octets[@]}"; do
if (( 10#$octet > 255 )); then
echo 'Invalid IPv4 gateway address.' >&2
exit 1
fi
done
listener=$(ss -H -lnt 'sport = :12345')
if [[ "$listener" != *'127.0.0.1:12345'* ]]; then
echo 'Start the redsocks listener on 127.0.0.1:12345 first.' >&2
exit 1
fi
iptables -w -t nat -S >/dev/null
if iptables -w -t nat -S "$CHAIN" >/dev/null 2>&1; then
echo "$CHAIN already exists; inspect the previous setup first." >&2
exit 1
fi
created=0
cleanup() {
status=$?
trap - EXIT
if (( status != 0 && created == 1 )); then
iptables -w -t nat -D OUTPUT -p tcp \
-m owner --uid-owner "$SIM_UID" -j "$CHAIN" 2>/dev/null || true
iptables -w -t nat -F "$CHAIN" || true
iptables -w -t nat -X "$CHAIN" || true
fi
exit "$status"
}
trap cleanup EXIT
iptables -w -t nat -N "$CHAIN"
created=1
iptables -w -t nat -A "$CHAIN" -d "$PROXY_IPV4/32" -j RETURN
for cidr in \
0.0.0.0/8 10.0.0.0/8 100.64.0.0/10 127.0.0.0/8 \
169.254.0.0/16 172.16.0.0/12 192.168.0.0/16 \
224.0.0.0/4 240.0.0.0/4
do
iptables -w -t nat -A "$CHAIN" -d "$cidr" -j RETURN
done
iptables -w -t nat -A "$CHAIN" \
-p tcp -j REDIRECT --to-ports 12345
iptables -w -t nat -A OUTPUT \
-p tcp -m owner --uid-owner "$SIM_UID" -j "$CHAIN"
echo 'Rules installed. Check the simulator exit IP next.'
Run it from the directory where you saved it:
sudo bash ./agent-sim-route.sh
The gateway exclusion prevents upstream connections from looping back into redsocks. Local and private-network exclusions preserve common internal connections. Add any other management destinations before the final redirect rule. These rules select all matching TCP traffic under that user, so run the model API controller under another account if only simulator traffic should be proxied.
The rules are temporary and do not survive a reboot. If another firewall manager controls this host, integrate them with that manager before using them as a persistent configuration.
Step 4: Account for protocol boundaries
This is IPv4 TCP forwarding, not full-device tunneling. UDP DNS queries may still use the host resolver; QUIC uses UDP; IPv6 is outside the IPv4 rules. Private and excluded destinations also bypass the proxy.
For applications that require UDP or IPv6, configure those routes separately before running the workload.
Step 5: Keep a rollback command
Stop the simulator workload first. Replace the username and run this block to remove the OUTPUT jump before deleting the chain:
(
set -eu
SIM_USER='YOUR_SIMULATOR_LINUX_USER'
SIM_UID=$(id -u "$SIM_USER")
sudo iptables -w -t nat -D OUTPUT \
-p tcp -m owner --uid-owner "$SIM_UID" -j AGENT_SIM_TCP
sudo iptables -w -t nat -F AGENT_SIM_TCP
sudo iptables -w -t nat -X AGENT_SIM_TCP
)
If the first command fails, inspect the existing rules before continuing. These commands remove this routing configuration; do not flush the entire firewall.
Check the Exit Inside the Simulator
In a shell logged in as the dedicated simulator account, open a fresh connection after installing the rules:
agent-sim up
agent-sim open https://api.ipify.org
agent-sim snapshot
Read the address displayed inside the simulator and compare it with the SOCKS5 request from Section 2. The addresses should match. If they differ, check the socket owner and routing counters below. Then open:
agent-sim open https://ipinfo.io
Use ipinfo.io alongside your Rola dashboard’s assigned region to verify the simulator’s exit IP and target geolocation. Compare the exit address with the SOCKS5 result from Section 2; if the reported location differs from your target, compare another IP lookup service before changing the endpoint.
If the exit is unchanged, inspect the routing counters:
sudo iptables -t nat -L AGENT_SIM_TCP -n -v
NAT counters primarily reflect new connections. Open a fresh connection before interpreting them. No matching traffic may indicate another socket owner, a forwarded network path, an earlier firewall rule, or a protocol outside this recipe.
Complete the check in the application you plan to automate. For an app you control, use server-side request logs or an in-app diagnostic endpoint to confirm its public source address.
Network Isolation for Multiple Simulators
For a straightforward two-device setup, use two Linux hosts or VMs. Configure Rola endpoint A in environment A and endpoint B in environment B, following Sections 2–4 on each. Check that each simulator displays its assigned exit and that the two exits differ.
| Device | Routing boundary | Upstream configuration | Check |
|---|---|---|---|
| Device A | Linux host or VM A | Rola endpoint A | Compare its displayed IP with endpoint A’s curl result |
| Device B | Linux host or VM B | Rola endpoint B | Compare its displayed IP with endpoint B’s curl result |
For per-user routing on one host, give each simulator a separate socket-owning Linux user and a separate upstream endpoint. Independent hosts or network namespaces provide alternative routing boundaries.
On a single host, Agent-Sim’s pool commands manage device availability. They do not assign proxy endpoints. Hold the device while checking its exit, then release it:
agent-sim pool up 3
phone=$(agent-sim pool take) || exit 1
if [ -z "$phone" ]; then
echo 'No device was returned.' >&2
exit 1
fi
agent-sim --device "$phone" open https://api.ipify.org
agent-sim --device "$phone" snapshot
# Record the displayed address before releasing the device.
agent-sim pool release "$phone"
Multiple phones selected by one owner-based rule share its upstream endpoint. When a shared service owns every phone’s connections, use independent hosts or VMs to separate their exits.
agent-sim pool release restarts the simulator instance in the background, so recheck the exit IP after acquiring a recycled device.
Separate Website Limits from LLM API Limits
Residential proxies change the public source address when traffic follows that route. They do not increase a model provider’s quota.
| Symptom | Possible cause | Response |
|---|---|---|
| Website returns 429 | IP, account, session, endpoint, or service-wide limit | Read the response, honor Retry-After, reduce concurrency, and identify the limit’s scope |
| Website returns 403 | Authentication, permissions, regional policy, or anti-abuse controls | Resolve the specific access issue rather than assuming a different IP will fix it |
| HTTP proxy returns 407 | Proxy authentication failed | Check the supplied credentials and endpoint access method; repeat the endpoint check |
| SOCKS5 authentication fails | Credentials or access method do not match | Correct the SOCKS5 credentials; this need not appear as HTTP 407 |
| Gateway hostname cannot be resolved | DNS failure or incorrect hostname | Correct the gateway name or restore host DNS before configuring routing |
| Connection is refused or times out | Wrong port, unreachable endpoint, or firewall restriction | Check the gateway and port, then repeat the timed curl request |
| LLM API reports RPM/TPM limits | Shared request or token allowance | Queue requests and manage total concurrency and token usage |
| Host proxy request works but simulator exit is unchanged | Traffic misses the configured route | Inspect socket ownership, namespaces, firewall counters, and protocol |
| Multiple phones share an exit | Shared routing or upstream assignment | Review the endpoint mapping and network boundaries |
Use bounded exponential backoff with jitter when implementing retries. Honor Retry-After when the service supplies it, and stop after a defined retry limit. Manage account-level and service-wide limits across the whole simulator pool.
For LLM usage, budget across the whole pool. Agent-Sim actions return the resulting screen, so use that response before requesting another snapshot. Reduce duplicate screenshots and redundant accessibility-tree text while preserving the information the agent needs.
Set pacing from the provider’s rate-limit response and the pool’s combined request and token usage.