如果是浏览器端的js,这个是无法实现的。如果是服务端的nodejs,则可以尝试这样做:假设此时你有两块网卡,ip分别是ip1和ip2。则可以尝试创建两个不同的http.Agent(具体请参考文档https://nodejs.org/api/http.h...),分别绑定ip1和ip2,然后用不同的agent去发送http请求,则相当于用不同的网卡去发送http请求了补充一段democonst http = require('http'); const keepAliveAgent = new http.Agent({ keepAlive: true, localAddress: "192.168.28.103",//指定发送方的ip localPort: 7777,//指定发送方的port host: "142.12.10.89", port: 7777 }); const options = { agent: keepAliveAgent }; http.request(options, () => { });
http.Agent
(具体请参考文档https://nodejs.org/api/http.h...),分别绑定ip1和ip2,然后用不同的agent去发送http请求,则相当于用不同的网卡去发送http请求了补充一段demo