What user agent does curl send by default?
A short string with its version, such as curl/8.5.0 on Ubuntu 24.04 or curl/8.14.1 on Debian 13. See it with verbose mode, where request headers are printed with a > prefix:
curl -sv -o /dev/null https://shop.example.net/ 2>&1 | grep -i '^> user-agent'
Servers use the header for statistics, for picking mobile or desktop layouts and sometimes for access rules. Some firewalls and web application filters treat the default curl agent as automation and answer differently than they would for a browser.
How do I set a different agent?
Use -A, short for --user-agent:
curl -A "ShopUptimeCheck/2.1 (+https://status.example.net)" https://shop.example.net/health curl --user-agent "Mozilla/5.0 (X11; Linux x86_64; rv:133.0) Gecko/20100101 Firefox/133.0" -I https://shop.example.net/
The first form is good practice for your own tools: a name, a version and a contact URL tell whoever reads the logs what the client is. The second mimics a desktop browser, useful for checking what real visitors receive from your site.
You can also set the header directly with -H "User-Agent: ShopUptimeCheck/2.1". If both -A and -H are given, the -H value wins.
How do I send no user agent at all?
curl -A "" https://shop.example.net/ # removes the header curl -H "User-Agent;" https://shop.example.net/ # sends it with an empty value
The semicolon form is curl's way of sending a header with an empty value. These are handy for testing how a server or a log parser handles clients that do not identify themselves.
How do I make a custom agent the default?
Put it in ~/.curlrc, read by curl at every start:
user-agent = "OpsToolkit/1.0 (+mailto:ops@example.net)" connect-timeout = 10
Scripts that must behave the same for every user should pass flags explicitly, or start curl with -q to ignore personal config files.
How do I test agent-based rules on my own server?
Run the same request with different agents and compare the status codes:
for ua in "curl/8.5.0" "Mozilla/5.0 (iPhone; CPU iPhone OS 18_1 like Mac OS X)" "BadScraper/0.1"; do
printf '%-60s ' "$ua"; curl -s -o /dev/null -w '%{http_code} %{size_download}\n' -A "$ua" https://shop.example.net/
done
On nginx, agent rules usually live in a map block:
map $http_user_agent $deny_ua {
default 0;
~*badscraper 1;
~*masscan 1;
}
server {
if ($deny_ua) { return 403; }
}
Keep such lists short and specific. User agents are trivially faked, so they are a filter for polite or lazy clients, not security. Real protection against abusive traffic comes from rate limits such as nginx limit_req, firewall rules and, for floods, the edge DDoS filtering in front of every machine, described in Edge DDoS filtering.
How do I see which agents hit my server?
The default combined log format in nginx and Apache ends with the user agent in quotes. Count the most common ones:
awk -F'"' '{print $6}' /var/log/nginx/access.log | sort | uniq -c | sort -rn | head -15
A sudden new agent at the top often explains a jump in outgoing traffic. Since each machine includes 15 TB of outgoing traffic a month, or 5 TB in Singapore, an aggressive crawler is worth spotting early: rate-limit it or block it before it eats into the allowance.
Which other request details go with the agent?
| Flag | Sets |
|---|---|
-e / --referer | The Referer header |
-H "Accept-Language: de-DE" | Preferred language, to test translated pages |
--compressed | Asks for gzip or brotli and decodes it |
-b / -c | Send or store cookies |
--resolve host:443:203.0.113.25 | Test a new machine before changing DNS |
The last one is especially useful during a migration: point the request at the new machine's address while keeping the real host name, so TLS and virtual hosts behave exactly as they will after the DNS switch.
Keep Reading
Edge DDoS filtering
How common volumetric attacks are filtered at the network edge before they reach your ports, and what you still handle on the box.
OpenOutbound traffic allowance
How the 15 TB monthly egress allowance works, what it means per day and per second, and why inbound data costs nothing.
OpenOnline stores
WooCommerce, Magento or a headless shop on a box sized for catalog size, checkout load and sale-day peaks.
OpenTelnet vs SSH
Why Telnet is never used for logins anymore, the one job it still does well and the modern tools that replace even that.
OpenFAQ
Quick Answers
Use -A followed by the string, or --user-agent, or -H "User-Agent: ...".
curl followed by its version number, for example curl/8.5.0 on Ubuntu 24.04.
Pass -A with an empty string; curl then sends no User-Agent header.
Yes. Add a user-agent line to ~/.curlrc.
Only a weak filter, since agents are easy to fake. Use rate limits and firewall rules for real protection.