Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Opensmtpd fails to start when IPv6 is semi-disabled #1108

Open
birdie-github opened this issue Dec 13, 2020 · 6 comments
Open

Opensmtpd fails to start when IPv6 is semi-disabled #1108

birdie-github opened this issue Dec 13, 2020 · 6 comments
Assignees

Comments

@birdie-github
Copy link

Under Linux if you disable IPv6 support this way:

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

Opensmtpd will fail to start:

smtpd[]: pony express: smtpd: bind: Cannot assign requested address
smtpd[]: smtpd: process pony socket closed

This is a bug, please fix.

ifconfig lo
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 13847  bytes 1118878 (1.0 MiB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 13847  bytes 1118878 (1.0 MiB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

So technically IPv6 support is there but the loopback interface doesn't have an IPv6 address assigned.

@poolpOrg poolpOrg self-assigned this Dec 13, 2020
@poolpOrg
Copy link
Member

Can you provide more details, such as the distro you're using ?

I have just tested on an Ubuntu and:

root@vultr:~/OpenSMTPD# cat /etc/issue.net 
Ubuntu 20.10
root@vultr:~/OpenSMTPD# uname -srm
Linux 5.8.0-29-generic x86_64
root@vultr:~/OpenSMTPD# ifconfig lo
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        inet6 ::1  prefixlen 128  scopeid 0x10<host>
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 164  bytes 13510 (13.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 164  bytes 13510 (13.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@vultr:~/OpenSMTPD# grep ^listen /tmp/opensmtpd/etc/smtpd.conf 
listen on lo
root@vultr:~/OpenSMTPD# /tmp/opensmtpd/sbin/smtpd -d
info: OpenSMTPD 6.7.0-portable starting
^CExiting
root@vultr:~/OpenSMTPD# sysctl net.ipv6.conf.default.disable_ipv6=1
net.ipv6.conf.default.disable_ipv6 = 1
root@vultr:~/OpenSMTPD# sysctl net.ipv6.conf.all.disable_ipv6=1
net.ipv6.conf.all.disable_ipv6 = 1
root@vultr:~/OpenSMTPD# ifconfig lo
lo: flags=73<UP,LOOPBACK,RUNNING>  mtu 65536
        inet 127.0.0.1  netmask 255.0.0.0
        loop  txqueuelen 1000  (Local Loopback)
        RX packets 164  bytes 13510 (13.5 KB)
        RX errors 0  dropped 0  overruns 0  frame 0
        TX packets 164  bytes 13510 (13.5 KB)
        TX errors 0  dropped 0 overruns 0  carrier 0  collisions 0

root@vultr:~/OpenSMTPD# /tmp/opensmtpd/sbin/smtpd -d
info: OpenSMTPD 6.7.0-portable starting
^CExiting
root@vultr:~/OpenSMTPD#

At least on that Linux, it works as expected

@birdie-github
Copy link
Author

birdie-github commented Dec 13, 2020

You haven't disabled IPv6 like I've shown by using two sysctl parameters.

Compare your ifconfig lo interface and mine - mine is missing inet6 ::1.

The distro doesn't matter as we are talking about core networking which is the same between distros.

@poolpOrg
Copy link
Member

poolpOrg commented Dec 14, 2020

Read the entire sequence I pasted 🙂

I setup a brand new Linux with inet6, showed the ifconfig with ::1, started the daemon in foreground successfully, THEN disabled inet6 with both sysctl, showed the ifconfig without ::1 and started the daemon in foreground again successfully.

Did I do it wrong and not see ?

As for the distro, I don't want to invest time in tracking a bug if I have partial information, let me decide if the distro matters when I can reproduce the issue on the same environment as you. I recently spent days tracking a bug in something that wasn't supposed to be different between distros but ended up being subtly different between a glibc and a musl distro.

@birdie-github
Copy link
Author

birdie-github commented Dec 14, 2020

My bad :-( My distro is Fedora 33. Loopback is not the only interface that I have, the other has a link-local IPv6 address attached to it but not lo. E.g.

enp3s0: flags=4163<UP,BROADCAST,RUNNING,MULTICAST>  mtu 1500
        inet 192.168.0.100  netmask 255.255.255.0  broadcast 192.168.0.255
        inet6 fe80::redacted  prefixlen 64  scopeid 0x20<link>

Strace shows this:

1141613 setsockopt(9, SOL_SOCKET, SO_REUSEADDR, [1], 4 <unfinished ...>
1141610 pipe2( <unfinished ...>
1141612 connect(7, {sa_family=AF_UNIX, sun_path="/var/run/nscd/socket"}, 110 <unfinished ...>
1141609 recvmsg(7,  <unfinished ...>
1141613 <... setsockopt resumed>)       = 0
1141611 geteuid( <unfinished ...>
1141610 <... pipe2 resumed>[7, 8], O_NONBLOCK|O_CLOEXEC) = 0
1141613 setsockopt(9, SOL_IPV6, IPV6_V6ONLY, [1], 4 <unfinished ...>
1141612 <... connect resumed>)          = -1 ENOENT (No such file or directory)
1141611 <... geteuid resumed>)          = 983
1141609 <... recvmsg resumed>{msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="-\0\0\0\20\0\0\0\0\0\0\0mk\21\0", iov_len=65535}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0) = 16
1141610 getuid( <unfinished ...>
1141613 <... setsockopt resumed>)       = 0
1141612 close(7 <unfinished ...>
1141611 getgid( <unfinished ...>
1141609 sendmsg(8, {msg_name=NULL, msg_namelen=0, msg_iov=[{iov_base="-\0\0\0\20\0\0\0\0\0\0\0ik\21\0", iov_len=16}], msg_iovlen=1, msg_controllen=0, msg_flags=0}, 0 <unfinished ...>
1141613 bind(9, {sa_family=AF_INET6, sin6_port=htons(25), sin6_flowinfo=htonl(0), inet_pton(AF_INET6, "::1", &sin6_addr), sin6_scope_id=0}, 28 <unfinished ...>
1141610 <... getuid resumed>)           = 983
1141609 <... sendmsg resumed>)          = 16
1141612 <... close resumed>)            = 0
1141611 <... getgid resumed>)           = 976
1141614 <... poll resumed>)             = 1 ([{fd=3, revents=POLLIN}])
1141613 <... bind resumed>)             = -1 EADDRNOTAVAIL (Cannot assign requested address)
1141610 geteuid( <unfinished ...>
1141609 poll([{fd=8, events=POLLIN}], 1, 10000 <unfinished ...>
1141614 socket(AF_INET, SOCK_DGRAM, IPPROTO_IP <unfinished ...>
1141612 socket(AF_UNIX, SOCK_STREAM|SOCK_CLOEXEC|SOCK_NONBLOCK, 0 <unfinished ...>
1141611 getegid( <unfinished ...>
1141613 write(2, "pony express: smtpd: bind: Canno"..., 59 <unfinished ...>

So for some reasons the daemon sees ::1 which is not there.

@poolpOrg
Copy link
Member

Thanks, will try to reproduce !

@vgratian
Copy link

I had the same issue as the OP, disabled IPv6 on Debian and OpenSmtpd failed to restart. Then I looked at my server network settings (VPS): I have IPv4 and IPv6, and IPv6 is tagged as "first IP".

I looked again in my SMPT config, I saw this line:
listen on localhost port 10028 tag DKIM_OUT

I changed it into:
listen on 127.0.0.1 port 10028 tag DKIM_OUT

Restarted OpenSmtpd and it worked.

Btw., I disabled IPv6 because outgoing email to Google was rejected because "Our system has detected that this message does not meet IPv6 sending guidelines regarding PTR records and authentication".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants