# Send http request through specific network interface using HTTP.jl

**URL:** <https://discourse.julialang.org/t/send-http-request-through-specific-network-interface-using-http-jl/81777>\
**Category:** Web Stack\
**Tags:** question\
**Created:** [May 27, 2022, 11:41am UTC](https://discourse.julialang.org/t/send-http-request-through-specific-network-interface-using-http-jl/81777 "2022-05-27T11:41:20Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Anastas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/anastas/32/36652_2.png) [@Anastas](https://discourse.julialang.org/u/Anastas)\
**Post date:** [May 27, 2022, 11:41am UTC](https://discourse.julialang.org/t/send-http-request-through-specific-network-interface-using-http-jl/81777/1 "2022-05-27T11:41:20Z")

</div>

Hello, every one  
I want to send request through specific network interface using HTTP.jl like it works in [here](https://stackoverflow.com/questions/48996494/send-http-request-through-specific-network-interface) . In lib python requests it works correct. Or if to use curl, request should look like this:  
`curl --interface <ip/name_of_interface> <host>`

But in HTTP.jl I didnt find this feature. if I send request, my server is receiving request from **tun0** interface.  
Does anyone know how this can be realize using the HTTP package. How to select the desired interface from the HTTP package

---

<div class="post-metadata">

**Author:** ![jd-foster](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/jd-foster/32/35824_2.png) [@jd-foster](https://discourse.julialang.org/u/jd-foster)\
**Post date:** [May 27, 2022, 12:30pm UTC](https://discourse.julialang.org/t/send-http-request-through-specific-network-interface-using-http-jl/81777/2 "2022-05-27T12:30:31Z")

</div>

I don’t know about HTTP.jl, but you can do this in the lower level [LibCURL.jl](https://github.com/JuliaWeb/LibCURL.jl) wrapper as

```julia
using LibCURL

# init a curl handle
curl = curl_easy_init()
curl_easy_setopt(curl, CURLOPT_URL, "https://docs.julialang.org")
curl_easy_setopt(curl, CURLOPT_INTERFACE, "eth0");
ret = curl_easy_perform(curl)

```

Not sure if this is useful to your task.  
(Ref: [CURLOPT\_INTERFACE](https://curl.se/libcurl/c/CURLOPT_INTERFACE.html))

---

<div class="post-metadata">

**Author:** ![tk3369](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/tk3369/32/2824_2.png) [@tk3369](https://discourse.julialang.org/u/tk3369)\
**Post date:** [May 29, 2022, 5:08am UTC](https://discourse.julialang.org/t/send-http-request-through-specific-network-interface-using-http-jl/81777/3 "2022-05-29T05:08:50Z")

</div>

After reviewing [HTTP.jl’s source code](https://github.com/JuliaWeb/HTTP.jl/blob/6714dcb25ac718f8ed51e03217cc3ef64aa4ce26/src/ConnectionPool.jl#L402-L403), I don’t think it supports binding to a different local interface. The good news is that it doesn’t seem to be too difficult to modify the code to accept another IP address via the [`kw` keyword argument](https://github.com/JuliaWeb/HTTP.jl/blob/6714dcb25ac718f8ed51e03217cc3ef64aa4ce26/src/ConnectionPool.jl#L379). Perhaps you can quick hack together something if that’s really needed 😉
