<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom"><title>The Wombelix Post - failed</title><link href="https://dominik.wombacher.cc/" rel="alternate"/><link href="/feeds/tag_failed.atom.xml" rel="self"/><id>https://dominik.wombacher.cc/</id><updated>2022-03-02T00:00:00+01:00</updated><entry><title>sshd error - Bind to port failed: Cannot assign requested address</title><link href="https://dominik.wombacher.cc/posts/sshd_error_bind_to_port_failed_cannot_assign_requested_address.html" rel="alternate"/><published>2022-03-02T00:00:00+01:00</published><updated>2022-03-02T00:00:00+01:00</updated><author><name>Dominik Wombacher</name></author><id>tag:dominik.wombacher.cc,2022-03-02:/posts/sshd_error_bind_to_port_failed_cannot_assign_requested_address.html</id><summary type="html">&lt;!-- SPDX-FileCopyrightText: 2023 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I faced a very weird issue today, sshd failed to start on boot because &lt;em&gt;ListenAddress&lt;/em&gt; was set
but &lt;em&gt;network.target&lt;/em&gt; doesn't mean IP addresses are already assigned and ready. So  ... &lt;a class="read-more" href="/posts/sshd_error_bind_to_port_failed_cannot_assign_requested_address.html"&gt; [read more]&lt;/a&gt;&lt;/p&gt;</summary><content type="html">&lt;!-- SPDX-FileCopyrightText: 2023 Dominik Wombacher &lt;dominik@wombacher.cc&gt; --&gt;
&lt;!--  --&gt;
&lt;!-- SPDX-License-Identifier: CC-BY-SA-4.0 --&gt;
&lt;p&gt;I faced a very weird issue today, sshd failed to start on boot because &lt;em&gt;ListenAddress&lt;/em&gt; was set
but &lt;em&gt;network.target&lt;/em&gt; doesn't mean IP addresses are already assigned and ready. So the configured
IP isn't available, therefore sshd can't bind a Port and failed with &lt;em&gt;fatal: Cannot bind any address&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;I thought this can be fixed by adjusting the sshd systemd unit, everything I found online also pointed
into that direction, for example a &lt;a class="reference external" href="https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982950"&gt;Debian&lt;/a&gt;
(Archive: &lt;a class="reference external" href="https://web.archive.org/web/20220302224510/https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982950"&gt;[1]&lt;/a&gt;,
&lt;a class="reference external" href="https://archive.today/2022.03.02-224450/https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=982950"&gt;[2]&lt;/a&gt;)
and &lt;a class="reference external" href="https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/216847/"&gt;Ubuntu&lt;/a&gt;
(Archive: &lt;a class="reference external" href="https://web.archive.org/web/20210901133033/https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/216847/"&gt;[1]&lt;/a&gt;,
&lt;a class="reference external" href="https://archive.today/2022.03.02-224617/https://bugs.launchpad.net/ubuntu/+source/openssh/+bug/216847/"&gt;[2]&lt;/a&gt;) Bug report.&lt;/p&gt;
&lt;pre class="code text literal-block"&gt;
/etc/systemd/system/ssh.service.d/override.conf

[Unit]
After=network-online.target auditd.service

&lt;/pre&gt;
&lt;p&gt;The above systemd override seem to be one of the popular solutions which works for a lot of people.
Unfortunately none of the various After/Wants combinations worked in my case on Debian 11.&lt;/p&gt;
&lt;p&gt;I had to go with the workaround to allow system wide port binding to not (yet) assigned IP addresses
by adjusting two sysctl values as described on &lt;a class="reference external" href="https://serverfault.com/a/941426"&gt;serverfault&lt;/a&gt;
(Archive: &lt;a class="reference external" href="https://web.archive.org/web/20220302224659/https://serverfault.com/questions/941421/servers-fail-to-bind-to-addresses-at-boot/941426"&gt;[1]&lt;/a&gt;,
&lt;a class="reference external" href="https://archive.today/2022.03.02-224737/https://serverfault.com/questions/941421/servers-fail-to-bind-to-addresses-at-boot/941426%23941426"&gt;[2]&lt;/a&gt;).&lt;/p&gt;
&lt;pre class="code text literal-block"&gt;
net.ipv4.ip_nonlocal_bind=1
net.ipv6.ip_nonlocal_bind=1

&lt;/pre&gt;
&lt;p&gt;Probably not the most elegant solution but it's working and due to the fact that multiple IP addresses are
assigned to the Server, I have to specify on which the SSH Daemon is listening and can't just let em bind to all.&lt;/p&gt;
</content><category term="Linux"/><category term="sshd"/><category term="error"/><category term="failed"/><category term="system"/><category term="linux"/><category term="debian"/></entry></feed>