如何在特定接口上使用cURL

时间:2022-06-01 20:00:24

I am developing a code in c, which simply FTPs the files on FTP server by using curl utility, by following this example

我正在开发一个c代码,它通过使用curl实用程序简单地FTP服务器上的文件,遵循这个例子

now i have one simple thing to do, specify curl to use particular interface (IP) of the server for upload, as other interface of the server is associated with other socket connection.

现在我有一个简单的事情要做,指定curl使用服务器的特定接口(IP)进行上传,因为服务器的其他接口与其他套接字连接相关联。

is there any way to do it?

有什么办法吗?

2 个解决方案

#1


19  

Seems like curl support --interface option

看起来像curl support --interface选项

curl --interface eth0 

#2


-1  

Your're asking to specify the server side interface based on its IP, right? (not your client side interface? in this later case, curl option --interface <name> is fine)

您要求根据其IP指定服务器端接口,对吗? (不是你的客户端界面?在后面的例子中,curl选项--interface 很好)

Then you can use the IP in the URL.

然后,您可以使用URL中的IP。

Say 216.58.211.110 is google.com from my home, then:

从我家里说216.58.211.110是google.com,然后:

$ curl http://216.58.211.110/index.html
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/index.html">here</A>.
</BODY></HTML>

#1


19  

Seems like curl support --interface option

看起来像curl support --interface选项

curl --interface eth0 

#2


-1  

Your're asking to specify the server side interface based on its IP, right? (not your client side interface? in this later case, curl option --interface <name> is fine)

您要求根据其IP指定服务器端接口,对吗? (不是你的客户端界面?在后面的例子中,curl选项--interface 很好)

Then you can use the IP in the URL.

然后,您可以使用URL中的IP。

Say 216.58.211.110 is google.com from my home, then:

从我家里说216.58.211.110是google.com,然后:

$ curl http://216.58.211.110/index.html
<HTML><HEAD><meta http-equiv="content-type" content="text/html;charset=utf-8">
<TITLE>301 Moved</TITLE></HEAD><BODY>
<H1>301 Moved</H1>
The document has moved
<A HREF="http://www.google.com/index.html">here</A>.
</BODY></HTML>