Rust 多本地 IP 绑定发起 HTTP 请求:将请求绑定到指定本地 IPv4,支持并发与连接复用。
Rust source-bound multi-IP HTTP requests: Bind requests to specific local IPv4s with concurrency and connection reuse.
轻量级命令行工具,使用指定本地 IPv4 地址作为出站地址,请求 https://ip.me 并打印返回的公网 IP。
Simple CLI tool to query public IPs using specific local IPv4 addresses as egress via https://ip.me.
- rust multi ip http
- rust source-bound http
- rust bind local address
- rust per ip http
- rust multiple interfaces
- reqwest local_address
- multi egress ip
- outbound ip
- iface public ip
- multi-ip http client
-
发现本机 IPv4 地址(过滤回环与常见虚拟网卡)
-
使用给定 IPv4 作为本地绑定地址发起请求,打印返回的公网 IP
-
User-Agent 固定为
curl/8.7.1 -
并发查询所有发现的 IPv4 地址
-
使用 Rustls 进行 TLS(无需系统 OpenSSL)
-
Discover local IPv4 addresses (filters loopback and common virtual interfaces)
-
Bind a
reqwestclient to a given local IPv4 and callhttps://ip.me, print the public IP -
Set User-Agent to
curl/8.7.1 -
Concurrently query all discovered IPv4 addresses
-
TLS via Rustls (no system OpenSSL required)
-
通过
if-addrs枚举网卡 -
过滤回环与常见虚拟/桥接网段(如 docker、veth、VirtualBox)
-
使用
ClientBuilder::local_address绑定到指定本地 IPv4 -
请求
https://ip.me,输出去除空白后的响应 -
Enumerates network interfaces via
if-addrs -
Filters out loopback and likely virtual/bridge ranges (e.g., docker, veth, VirtualBox)
-
Builds a
reqwestclient bound to a specific local IPv4 usingClientBuilder::local_address -
Requests
https://ip.meand prints the trimmed response
-
Rust 1.75+(2024 edition)
-
无需外部 OpenSSL(启用
rustls-tls特性) -
Rust 1.75+ (edition 2024)
-
No external OpenSSL required (uses
rustls-tlsfeature)
cargo build --releasecargo run --release预期输出示例 Expected output example:
Found IPv4 addresses:
192.168.1.10
10.0.0.5
Found 2 IPv4 addresses
Checking public IP for each local address:
Local: 192.168.1.10 -> Public: 203.0.113.45
Local: 10.0.0.5 -> Public: 203.0.113.45
默认会过滤:
- 接口名包含以下前缀:docker, br-, veth, virbr, vmnet, tun, tap, lo, dummy, bridge, vbox, vmware, utun
- 常见虚拟化地址段:172.17.0.0/16,172.18.0.0/16–172.31.0.0/16,192.168.56.0/24
你可以在 src/main.rs 中修改这些过滤规则。
By default, discovery filters out:
- Interface names containing: docker, br-, veth, virbr, vmnet, tun, tap, lo, dummy, bridge, vbox, vmware, utun
- Virtualization ranges: 172.17.0.0/16, 172.18.0.0/16–172.31.0.0/16, 192.168.56.0/24
You can adjust these filters in src/main.rs.
-
绑定本地 IPv4 只影响源地址选择;实际对外 IP 可能仍经由 NAT。
-
目标服务可能有频率限制;如需高频请求请在应用层做限速。
-
客户端默认使用连接池与 keep-alive,会完整读取响应以便复用连接。
-
Binding to a local IPv4 only controls source address selection; outbound IP may still be NATed.
-
Servers may rate-limit requests; add application-level rate limiting if you query frequently.
-
The client uses connection pooling and keep-alive by default. Responses are fully read to allow reuse.
-
本仓库不包含密钥或凭证。
-
自动扫描未发现 token、密码或嵌入式凭据。
-
程序仅向
https://ip.me发起请求并打印响应。 -
This repository does not contain secrets or private keys.
-
No tokens, passwords, or embedded credentials were found during an automated scan.
-
The tool performs outbound requests to
https://ip.meand prints the server response.
MIT