[PHP][Node.js] 指定特定的network interface送出請求
Linux
# curl --interface eth0:1
PHP
$url = "http://www.google.com";
$curlh = curl_init($url);
curl_setopt($curlh, CURLOPT_USERAGENT, $uagent);
curl_setopt($curlh, CURLOPT_INTERFACE, “888.888.888.888“);
curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curlh);
Ref: http://blog.unethost.com/php_assign_outgoing_ip_address/
Node.js
使用http.request中 , options可以帶 localAddress
也就是主機上的ip
or npm request module, options也可以帶 localAddress
Ref: https://stackoverflow.com/questions/15773672/node-js-http-request-using-network-interface
# curl --interface eth0:1
PHP
$url = "http://www.google.com";
$curlh = curl_init($url);
curl_setopt($curlh, CURLOPT_USERAGENT, $uagent);
curl_setopt($curlh, CURLOPT_INTERFACE, “888.888.888.888“);
curl_setopt($curlh, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($curlh);
Ref: http://blog.unethost.com/php_assign_outgoing_ip_address/
Node.js
使用http.request中 , options可以帶 localAddress
也就是主機上的ip
or npm request module, options也可以帶 localAddress
Ref: https://stackoverflow.com/questions/15773672/node-js-http-request-using-network-interface
留言
張貼留言