[ZBX-16082] If SourceIP= is set to IPv4 in /etc/zabbix/zabbix_proxy.conf, the curl should called with -4 flag. Created: 2019 May 04 Updated: 2019 Jun 13 Resolved: 2019 Jun 12 |
|
Status: | Closed |
Project: | ZABBIX BUGS AND ISSUES |
Component/s: | Proxy (P) |
Affects Version/s: | 4.2.1 |
Fix Version/s: | None |
Type: | Patch request | Priority: | Trivial |
Reporter: | Alex Grebenschikov | Assignee: | Viktors Tjarve |
Resolution: | Won't fix | Votes: | 0 |
Labels: | None | ||
Remaining Estimate: | Not Specified | ||
Time Spent: | Not Specified | ||
Original Estimate: | Not Specified | ||
Environment: |
|
Attachments: | debug_log5.txt |
Team: | Team A |
Sprint: | Sprint 52 (May 2019), Sprint 53 (Jun 2019) |
Description |
Steps to reproduce:
Result:
Expected:
Possible solution: If `SourceIP=` is set to `IPv4` in `/etc/zabbix/zabbix_proxy.conf`, the curl should called with `-4` flag. Regards, |
Comments |
Comment by Andrei Gushchin (Inactive) [ 2019 May 04 ] | |
Thank you for reporting this. if (NULL != CONFIG_SOURCE_IP) { if (CURLE_OK != (err = curl_easy_setopt(easyhandle, CURLOPT_INTERFACE, CONFIG_SOURCE_IP))) { *error = zbx_dsprintf(*error, "Cannot specify source interface for outgoing traffic: %s", curl_easy_strerror(err)); return FAIL; } } Do you have some issues with getting data? | |
Comment by Alex Grebenschikov [ 2019 May 04 ] | |
Thank you for your time. Here you are: CentOS Linux release 7.6.1810 (Core) curl 7.29.0 (x86_64-redhat-linux-gnu) libcurl/7.29.0 NSS/3.36 zlib/1.2.7 libidn/1.28 libssh2/1.4.3 installed from a basic CentOS repository. Connections from Zabbix Proxy per web-check fail. As curl fails to connect to a IPv6 with source ip set to IPv4. A web monitoring page in zabbix shows
in red, and no data retrieved. Confirmed through nginx's logs from a target server and tcpdump session. The IPv4 and IPv6 are added to one and the same eth0: eth0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST> mtu 1500 inet 1.2.3.4 netmask 255.255.254.0 broadcast 1.2.3.255 inet6 fe80::200:ff:fe42:8651 prefixlen 64 scopeid 0x20<link> inet6 1111:2222:db:1::1 prefixlen 64 scopeid 0x0<global> ether 00:00:00:42:86:51 txqueuelen 1000 (Ethernet) I hope it helps. | |
Comment by Alex Grebenschikov [ 2019 May 04 ] | |
So I believe you need to add CURL_IPRESOLVE_V4 for this case.
| |
Comment by Andrei Gushchin (Inactive) [ 2019 May 04 ] | |
Do domains in the web checks resolved to IPv4 or both? | |
Comment by Alex Grebenschikov [ 2019 May 04 ] | |
Resolve both to IPv6 and IPv4. | |
Comment by Andrei Gushchin (Inactive) [ 2019 May 04 ] | |
Thanks. Probably this makes sense. | |
Comment by Viktors Tjarve [ 2019 May 13 ] | |
Hi Alex, Is it possible that you shear more information how it is possible to reproduce this issue from within Zabbix? Also could you please add here the errors from log files of Zabbx proxy and server that are related to this issue? Does the error message appear in "Info" column in Web scenario page? Thanks | |
Comment by Alex Grebenschikov [ 2019 May 13 ] | |
Hello Viktors, Most details were already provided, anyway if you want them, here you are:
I really hope it is sufficient. Regards. | |
Comment by Alex Grebenschikov [ 2019 May 15 ] | |
Hello Viktors, If you need anything else, kindly let me know. I believe you might need to adjust the block
if (NULL != CONFIG_SOURCE_IP) { if (CURLE_OK != (err = curl_easy_setopt(easyhandle, CURLOPT_INTERFACE, CONFIG_SOURCE_IP))) { *error = zbx_dsprintf(*error, "Cannot specify source interface for outgoing traffic: %s", curl_easy_strerror(err)); return FAIL; } }
from https://github.com/zabbix/zabbix/blob/master/src/libs/zbxhttp/http.c#L52 and add a check of CONFIG_SOURCE_IP is IPv4, and if this is a case add instruction
curl_easy_setopt(easyhandle, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4);
Sorry, my knowledge of C-language allows me at the moment only reading. I've found this example: https://stackoverflow.com/a/3736377 Regards. | |
Comment by Viktors Tjarve [ 2019 May 15 ] | |
Hi Alex, Thanks for your input. The extra information you provided confirmed some of our suspicions. I have been able to reproduce this issue when messing with SourceIP parameter in conf file. Kind Regards, | |
Comment by Alex Grebenschikov [ 2019 May 16 ] | |
Hello Viktors, Thanks for the explanation. Kindly let me know if I can help you with anything else. Regards, | |
Comment by Alex Grebenschikov [ 2019 Jun 08 ] | |
Reported the issue to cURL developers here: https://github.com/curl/curl/issues/3993 Probably a quicker solution could be elaborated if to join the efforts.
Regards, | |
Comment by Viktors Tjarve [ 2019 Jun 11 ] | |
Hi Alex, | |
Comment by Alex Grebenschikov [ 2019 Jun 12 ] | |
Hello Viktors, Yes, I can confirm, the issue has been fixed with a custom `libcurl` build. The version `7.65.2` does not seem to be released yet. Anyway the master branch contains a fix. | |
Comment by Alex Grebenschikov [ 2019 Jun 12 ] | |
Fixed through upgrade of libcurl, bindlocal: detect and avoid IP version mismatches in bind() #4002 https://github.com/curl/curl/pull/4002
| |
Comment by Viktors Tjarve [ 2019 Jun 12 ] | |
Great. |