PGNet Dev
2020-Oct-15 21:52 UTC
how to set smtp-client -> submission_relay_host for IPv4 only?
On 10/15/20 2:02 PM, jeremy ardley wrote:>> how/where do I configure (just) the dovecot smtp-client -> submission_relay_host to only connect IPv4? > > It appears your host has A and AAAA records in your DNS. The clients will try IPV6 first if they see an AAAA record. > > If you don't need IPV6 for your host remove the AAAA record. All connections will then only use IPV4. > > If you need IPV6 for some other reason then create an alias DNS A record and point your clients to that insteadThat's not the issue. All my machines are dual stack. All my hosts' DNS records exist for both A & AAAA records. Some services listen on only IPv4, some only on IPv6, some both. For Dovecot _listeners_ it's trivial to set IPv4/6-only, or both, addresses. It's also trivial to set OTHER clients, connecting TO Dovecot, to use IPv4-only. I'm asking how/where to 'tell', via config, Dovecot's smtp-CLIENT, that's making to connection to the submission_relay_host, to use _only_ IPv4.
Aki Tuomi
2020-Oct-16 05:13 UTC
how to set smtp-client -> submission_relay_host for IPv4 only?
> On 16/10/2020 00:52 PGNet Dev <pgnet.dev at gmail.com> wrote: > > > On 10/15/20 2:02 PM, jeremy ardley wrote: > >> how/where do I configure (just) the dovecot smtp-client -> submission_relay_host to only connect IPv4? > > > > It appears your host has A and AAAA records in your DNS. The clients will try IPV6 first if they see an AAAA record. > > > > If you don't need IPV6 for your host remove the AAAA record. All connections will then only use IPV4. > > > > If you need IPV6 for some other reason then create an alias DNS A record and point your clients to that instead > > That's not the issue. > > All my machines are dual stack. > All my hosts' DNS records exist for both A & AAAA records. > > Some services listen on only IPv4, some only on IPv6, some both. > > For Dovecot _listeners_ it's trivial to set IPv4/6-only, or both, addresses. > > It's also trivial to set OTHER clients, connecting TO Dovecot, to use IPv4-only. > > I'm asking how/where to 'tell', via config, Dovecot's smtp-CLIENT, that's making to connection to the submission_relay_host, to use _only_ IPv4.There is currently no (other) way to do this than using /etc/hosts or specifying IPv4 address for the relay host. Aki
PGNet Dev
2020-Oct-16 17:32 UTC
how to set smtp-client -> submission_relay_host for IPv4 only?
On 10/15/20 10:13 PM, Aki Tuomi wrote:>> I'm asking how/where to 'tell', via config, Dovecot's smtp-CLIENT, that's making to connection to the submission_relay_host, to use _only_ IPv4. > > There is currently no (other) way to do this than using /etc/hosts or specifying IPv4 address for the relay host.just a quick look, but looks like the culprit here is the submission code call to "net_addr2ip()" src/submission/main.c (c) ... 193 static void main_stdio_run(const char *username) { struct mail_storage_service_input input; buffer_t *input_buf; const char *value, *error, *input_base64; i_zero(&input); input.module = input.service = "submission"; input.username = username != NULL ? username : getenv("USER"); if (input.username == NULL && IS_STANDALONE()) input.username = getlogin(); if (input.username == NULL) i_fatal("USER environment missing"); if ((value = getenv("IP")) != NULL) !!! (void)net_addr2ip(value, &input.remote_ip); if ((value = getenv("LOCAL_IP")) != NULL) (void)net_addr2ip(value, &input.local_ip); input_base64 = getenv("CLIENT_INPUT"); input_buf = input_base64 == NULL ? NULL : t_base64_decode_str(input_base64); if (client_create_from_input(&input, STDIN_FILENO, STDOUT_FILENO, input_buf, &error) < 0) i_fatal("%s", error); } ... which includes ipv6-first code, ./src/lib/net.c ... 932 int net_addr2ip(const char *addr, struct ip_addr *ip) { int ret; if (net_addr2ip_inet4_fast(addr, ip)) return 0; if (strchr(addr, ':') != NULL) { !!! /* IPv6 */ T_BEGIN { if (addr[0] == '[') { /* allow [ipv6 addr] */ size_t len = strlen(addr); if (addr[len-1] == ']') addr = t_strndup(addr+1, len-2); } ret = inet_pton(AF_INET6, addr, &ip->u.ip6); } T_END; if (ret == 0) return -1; ip->family = AF_INET6; } else { /* IPv4 */ if (inet_aton(addr, &ip->u.ip4) == 0) return -1; ip->family = AF_INET; } return 0; } ... adding a config param, e.g., submission_relay_ip_family = {any:inet6:inet4} and wrapping the "src/lib/net.c" stanza, above, in 'if' conditionals based on its value should, iiuc, sufficiently instruct Dovecot to relay-submit over the intended AF. and stop causing the 'failed connect' error noise in logs.
Seemingly Similar Threads
- how to set smtp-client -> submission_relay_host for IPv4 only?
- how to set smtp-client -> submission_relay_host for IPv4 only?
- how to set smtp-client -> submission_relay_host for IPv4 only?
- how to set smtp-client -> submission_relay_host for IPv4 only?
- dovecot warns (non-fatal) "invalid EHLO response line: Unexpected character in EHLO keyword" connecting to submission relay ?