NOTIC-BUG: CURLOPT_INTERFACE with "INTERFACE Name"

Ohm J

Verified User
Joined
Aug 16, 2019
Messages
1,768
NGINX_APACHE + PHP-FPM
Code:
curl_setopt($ch, CURLOPT_INTERFACE, 'eth0' );

( it's only interface name, but IP Address can work normally )
it so weird with this problem,

Any one got same me ?



on command line can work normally
"curl --interface 'eth0' https://google.com"
"/usr/local/php74/bin/php test.php"

it's have problem only when on webserver ( NGINX_APACHE )



this is my version
Code:
PHP 7.4.15 (cli) (built: Feb 10 2021 20:52:31) ( NTS )
Copyright (c) The PHP Group
Zend Engine v3.4.0, Copyright (c) Zend Technologies
    with the ionCube PHP Loader + ionCube24 v10.4.5, Copyright (c) 2002-2020, by ionCube Ltd.
    with Zend OPcache v7.4.15, Copyright (c), by Zend Technologies

Code:
curl 7.74.0 (x86_64-pc-linux-gnu) libcurl/7.74.0 OpenSSL/1.1.1g-fips zlib/1.2.11 zstd/1.4.5 nghttp2/1.42.0
Release-Date: 2020-12-09
Protocols: dict file ftp ftps gopher http https imap imaps mqtt pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: alt-svc AsynchDNS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets zstd
 
Last edited:
Not completely you sure what you are asking. Based on your OS did you confirm the name of your interface.

Code:
ifconfig
or
Code:
ip a

My server interface name is
Code:
vtnet0
as an example. They are not always eth0.

--interface <name>Perform an operation using a specified interface. You can enter interface name, IP address or host name. An example could look like:
Code:
curl --interface eth0:1 http://www.netscape.com/

If this option is used several times, the last one will be used.

can you curl for the server on cmd line outside of DA?

Not sure it this helps or not.
 
Last edited:
I confirm on cmd line before posting at here, as mention here
Code:
on command line can work normally
"curl --interface 'eth0' https://google.com"
"/usr/local/php74/bin/php test.php"
it's working normally

with php code testing between eth0 and {ip_address}
only interface name ( eth0 ) can't use when run by webserver,

it report error like
Code:
(45) Couldn't bind to 'eth0'

it's so weird, I don't know what going on :(
rebuild webserver / php / curl, it's can't solve
 
Do you have Debian or FreeBSD? what OS?

Aslo are you using Short tags instead of full tags in PHP?
 
Code:
$ which curl
/usr/local/bin/curl
Do you thing it's cause by Directadmin CURL building ?

because old path
/usr/bin/curl

is 7.61 - base os installation


in custombuild log build php , it's detect 7.75.0
Code:
checking for cURL 7.10.5 or greater... libcurl 7.75.0

Code:
/usr/bin/curl --interface eth0 https://www.google.co.th
it's working normally
 
Last edited:
because old path
/usr/bin/curl
I got them both in Centos 8.3.2011
Code:
[root@server: ~]# whereis curl
curl: /usr/bin/curl /usr/local/bin/curl /usr/include/curl /usr/share/man/man1/curl.1.gz
the "which" command only shows the one in /usr/local/bin/ indeed, but whereis also shows the other one.

Just wondering... could it be that curl or direct access to eth0 can be accessed by root, but not by a non-root php script? Just guessing.
 
I try place some script in "/var/html/www/phpmyadmin" and get in by browser with ip_address/phpmyadmin/somescript.php
got same error result


this problem I got detect long time ago, but I don't have time to deal it,

so, It's just small problem, I don't worry in now, But I beware in future.
I will leave this thread to every one got same problem with me,
 
I got them both in Centos 8.3.2011
Code:
[root@server: ~]# whereis curl
curl: /usr/bin/curl /usr/local/bin/curl /usr/include/curl /usr/share/man/man1/curl.1.gz
the "which" command only shows the one in /usr/local/bin/ indeed, but whereis also shows the other one.

Just wondering... could it be that curl or direct access to eth0 can be accessed by root, but not by a non-root php script? Just guessing.
Yes this is what I am wondering are there 2 curl binaries on the system
 
Yes there are in my case. That is due to that curl was already installed before DA got installed.
After that, Custombuild also installed curl (curl=yes setting in options.conf) so that might explain 2 binaries.

Just checked. Custombuild is using an older version 7.75.0 while yum (OS install) is using 7.61.1.
I didn't expect custombuild to be that far behind. I don't know if that can cause issues, never had issues before though. Also got both installed on the Centos 7 servers.
 
This is here for the Admin to choose CB or OS binary.
See previous discussion.

You should use one or the other. Which is why I wondered if he had 2 curl binaries. As I can see that confusing the system.
 
Yes I've seen that thread before, but never had issues before with that and still don't.
I might remove one or the other, but first want to know which one is newer/better, I've got another thread for that. I don't want to go more off-topic here.
 
Back
Top