brewedbits.dev

Personal blog with guides and news on selfhosting, Linux and AI, from the Netherlands

nextDash nextdash --aboutYour bookmarks. Your terminal. checks your links knows your Docker host one container, no cloudLive demo →nextdash.cc ↗

Tip: curl --interface sends a request out of a chosen network interface

Curl
~/tips/tip-curl-interface-source-address

curl --interface wg0 -s -o /dev/null -w '%{local_ip}\n' https://example.com/

Forces a request to leave through a specific interface or source address.

With two uplinks or a VPN I want to know which route a request really takes.

curl --interface wg0 -s -o /dev/null -w '%{local_ip}\n' https://example.com/

--interface accepts an interface name, an IP address or a host name, and curl binds the connection to it. -w '%{local_ip}' prints the local address that was used, which proves the choice. A plain IP address is the safest form when the interface has several addresses. If routing or firewall rules do not allow replies on that interface the request just times out. Use -v to see which source address the connection starts from.

Further reading: curl manual

More Curl tips curl --trace-ascii – https://example.com/ Retry-After: 120 curl -fsS --fail-early \ url = "https://example.com/data/latest.json" curl -4 -s -o /dev/null -w '%{remote_ip} %{http_code}\n' https://example.com/ All Curl tips (71) All topics

Link