Discussion:
When your server boots too fast: How to slow it down?
(too old to reply)
Niklaas Baudet von Gersdorff
2016-06-11 17:48:49 UTC
Permalink
For the last days I have been wondering why some daemons don't
start during boot process e.g., ssh, tinc and postfix. Today
I noticed the following /var/log/messages:

8<----
Jun 11 17:52:52 box-hlm-03 postfix[908]: fatal: parameter inet_interfaces: no local interface found for <my-IPv6>
Jun 11 17:52:53 box-hlm-03 sshd[970]: error: Bind to port 22 on <my-IPv6> failed: Can't assign requested address.
8<----

`sockstat -46lj 0` shows that postfix isn't running at all and
sshd only listens on IPv4.

But if I issue

service sshd restart
service postfix restart
service tincd restart

all (re)start without any problems. Checking `sockstat`, then,
they listen on IPv4 and IPv6.

I assume that it takes a bit for my server to get its public
IPv6. So it isn't assigned when sshd, postfix, and tincd are
started; thus all of them (partly) fail. It's just an
assumption, the only idea I have to explain this behaviour.

Can I configure the machine to sleep a short while before
starting the programs mentioned above or after bringing the
public interface up, assigning the IP address?

Niklaas
Michael Sierchio
2016-06-11 18:23:53 UTC
Permalink
On Sat, Jun 11, 2016 at 10:48 AM, Niklaas Baudet von Gersdorff <
Post by Niklaas Baudet von Gersdorff
For the last days I have been wondering why some daemons don't
start during boot process e.g., ssh, tinc and postfix. Today
8<----
Jun 11 17:52:52 box-hlm-03 postfix[908]: fatal: parameter
inet_interfaces: no local interface found for <my-IPv6>
Jun 11 17:52:53 box-hlm-03 sshd[970]: error: Bind to port 22 on
<my-IPv6> failed: Can't assign requested address.
8<----
`sockstat -46lj 0` shows that postfix isn't running at all and
sshd only listens on IPv4.
But if I issue
service sshd restart
service postfix restart
service tincd restart
all (re)start without any problems. Checking `sockstat`, then,
they listen on IPv4 and IPv6.
I assume that it takes a bit for my server to get its public
IPv6. So it isn't assigned when sshd, postfix, and tincd are
started; thus all of them (partly) fail. It's just an
assumption, the only idea I have to explain this behaviour.
Assuming your external IP is assigned via DHCP... in /etc/rc.conf

ifconfig_<your-ext-if>="SYNCDHCP"

- M
Niklaas Baudet von Gersdorff
2016-06-11 19:32:25 UTC
Permalink
Post by Michael Sierchio
Assuming your external IP is assigned via DHCP... in /etc/rc.conf
ifconfig_<your-ext-if>="SYNCDHCP"
Indeed I had

ifconfig_vtnet0="DHCP"

in rc.conf because the public IPv4 is assigned by the router.
However, changing it to SYNCDHCP helped only partly. Now,
tincd starts but both postfix and sshd still fail.

Does SYNCDHCP also apply to IPv6?

I did some research in /etc/rc.d and found out that there is
also

synchronous_dhclient="YES"

Am I right assuming that it's the same as SYNCDHCP but for
*every* interface?

Niklaas
Niklaas Baudet von Gersdorff
2016-06-11 20:04:48 UTC
Permalink
Post by Niklaas Baudet von Gersdorff
in rc.conf because the public IPv4 is assigned by the router.
However, changing it to SYNCDHCP helped only partly. Now,
tincd starts but both postfix and sshd still fail.
Additionally to SYNCDHCP, I added the following three lines:

netwait_enable="YES"
netwait_if="<interface>"
netwait_ip="<IPv6>"

This solves the problem. But this also requires me to predict
the IPv6 that the server gets from the router. In this special
case I know it because my provider will only assign me one in
particular. But maybe there's something like SYNCDHCP for IPv6
too?

Niklaas
Mel Pilgrim
2016-06-14 19:24:36 UTC
Permalink
Post by Niklaas Baudet von Gersdorff
Post by Niklaas Baudet von Gersdorff
in rc.conf because the public IPv4 is assigned by the router.
However, changing it to SYNCDHCP helped only partly. Now,
tincd starts but both postfix and sshd still fail.
netwait_enable="YES"
netwait_if="<interface>"
netwait_ip="<IPv6>"
This solves the problem. But this also requires me to predict
the IPv6 that the server gets from the router. In this special
case I know it because my provider will only assign me one in
particular. But maybe there's something like SYNCDHCP for IPv6
too?
Statically configure the interface in rc.conf. You already have it
statically configured elsewhere in the system, so save yourself the race
condition headache and make it static in rc.conf, too.
Lowell Gilbert
2016-06-14 19:59:22 UTC
Permalink
Post by Niklaas Baudet von Gersdorff
Post by Niklaas Baudet von Gersdorff
in rc.conf because the public IPv4 is assigned by the router.
However, changing it to SYNCDHCP helped only partly. Now,
tincd starts but both postfix and sshd still fail.
I think you'd need the ports version of the DHCP client for working with
IPv6.
Post by Niklaas Baudet von Gersdorff
netwait_enable="YES"
netwait_if="<interface>"
netwait_ip="<IPv6>"
This solves the problem. But this also requires me to predict
the IPv6 that the server gets from the router.
No, it doesn't. You're supposed to put a *remote* address in that
variable, not a local one.

You can list any remote IP addresses in the variable that you
want, including, for example, public DNS servers. In particular, you
should do it for both IPv4 and IPv6.

Just out of interest, where did you get the idea of doing it this way?
Niklaas Baudet von Gersdorff
2016-06-15 05:46:55 UTC
Permalink
Post by Lowell Gilbert
Post by Niklaas Baudet von Gersdorff
netwait_enable="YES"
netwait_if="<interface>"
netwait_ip="<IPv6>"
This solves the problem. But this also requires me to predict
the IPv6 that the server gets from the router.
No, it doesn't. You're supposed to put a *remote* address in that
variable, not a local one.
I don't know why but I couldn't think about that option at all.
That makes totally sense.
Post by Lowell Gilbert
Just out of interest, where did you get the idea of doing it this way?
Since it had something to do with the boot process I skimmed
a bit over /etc/rc.d/* and stumbled upon /etc/rc.d/netwait and
read it. Although it says that one should prefer SYNCDHCP
(actually it says synchronous_dhclient="YES") at the very
beginning, I gave it a shot.
Post by Lowell Gilbert
Statically configure the interface in rc.conf. You already have it
statically configured elsewhere in the system, so save yourself the race
condition headache and make it static in rc.conf, too.
That's a good point too.

Niklaas

Loading...