Search code examples
rusthyper

How to bind a request to a specific network interface with Rust Hyper HTTP client?


I have a Linux server with multiple network interfaces. Each interface has its own IP address. How to force HTTP requests to use a specific interface by specifying its IP address? Just like curl --interface command line option.


Solution

  • You'd need to build your own HttpConnector probably starting from the vanilla connector, perhaps using net2::TcpBuilder.

    This is definitely something that seems like it should be easier, perhaps specified in the config. You might want to open an issue for hyper or submit a pull request if you implement it yourself.