I actually registered on opensource.com in order to be able to save a "thank you" comment for this article - big help for me.
I made a few changes to my implementation of your solution that I'll indicate here in-case it's helpful to to anyone:
1. Instead of writing a regular "simple/forking" systemd service unit, I wrote a "oneshot" service. I've pasted it below.
2. Instead of having the service invoke a shell script, I had it directly invoke sysctl --load=[FILE], where [FILE] was the name of the local drop-in file I placed in '/etc/sysctl.d' containing the ipv6 disable settings. One less file involved in a solution is a good thing.
3. In order to ensure the fix wasn't attempted too early during system-startup, I used the After = parameter in the service unit file to force to wait for the network to come online before triggering. This seems to be working for me thus far, and obviated the need for any kind of built-in time delay.
4. I chose to only directly load the single IPv6 settings file I'd created instead of running sysctl --system (which causes basically ALL system configuration files everywhere to be loaded), on the theory that minimizing the scope of impact this fix would have was another good thing.
Here's the oneshot service unit file I ended up going with (containing an attribution reference to your article which I again thank you for):
#################################################################################
# File Name : /etc/systemd/system/disable_ipv6.service
# Created By : wirerydr
# Creation Date : [2022-08-17 00:29]
# Last Modified : [2022-08-17 01:16]
# Description : Oneshot service to fully disable IPv6 during boot
#################################################################################
# Note: It appears that during boot, settings in '/etc/sysctl.d/*.conf' are not
# always applied. To mitigate that, this systemd oneshot service forces
# a settings file '/etc/sysctl.d/70-disable-ipv6.conf' to be
# applied that fully disables IPv6. This oneshot service is invoked during
# system startup, after reaching the systemd 'network-online' target.
#
# Derived from 'https://opensource.com/article/22/8/disable-ipv6' with thanks.
#################################################################################
#
[Unit]
Description = "Oneshot service to fully disable IPv6 at startup"
After = network-online.target
#
[Service]
Type = oneshot
RemainAfterExit = yes
ExecStart =/bin/bash -c "sysctl --load=/etc/sysctl.d/70-disable-ipv6.conf"
#
[Install]
WantedBy = multi-user.target
I actually registered on opensource.com in order to be able to save a "thank you" comment for this article - big help for me.
I made a few changes to my implementation of your solution that I'll indicate here in-case it's helpful to to anyone:
1. Instead of writing a regular "simple/forking" systemd service unit, I wrote a "oneshot" service. I've pasted it below.
2. Instead of having the service invoke a shell script, I had it directly invoke
sysctl --load=[FILE]
, where [FILE] was the name of the local drop-in file I placed in '/etc/sysctl.d' containing the ipv6 disable settings. One less file involved in a solution is a good thing.3. In order to ensure the fix wasn't attempted too early during system-startup, I used the
After =
parameter in the service unit file to force to wait for the network to come online before triggering. This seems to be working for me thus far, and obviated the need for any kind of built-in time delay.4. I chose to only directly load the single IPv6 settings file I'd created instead of running
sysctl --system
(which causes basically ALL system configuration files everywhere to be loaded), on the theory that minimizing the scope of impact this fix would have was another good thing.Here's the oneshot service unit file I ended up going with (containing an attribution reference to your article which I again thank you for):
#################################################################################
# File Name : /etc/systemd/system/disable_ipv6.service
# Created By : wirerydr
# Creation Date : [2022-08-17 00:29]
# Last Modified : [2022-08-17 01:16]
# Description : Oneshot service to fully disable IPv6 during boot
#################################################################################
# Note: It appears that during boot, settings in '/etc/sysctl.d/*.conf' are not
# always applied. To mitigate that, this systemd oneshot service forces
# a settings file '/etc/sysctl.d/70-disable-ipv6.conf' to be
# applied that fully disables IPv6. This oneshot service is invoked during
# system startup, after reaching the systemd 'network-online' target.
#
# Derived from 'https://opensource.com/article/22/8/disable-ipv6' with thanks.
#################################################################################
#
[Unit]
Description = "Oneshot service to fully disable IPv6 at startup"
After = network-online.target
#
[Service]
Type = oneshot
RemainAfterExit = yes
ExecStart =/bin/bash -c "sysctl --load=/etc/sysctl.d/70-disable-ipv6.conf"
#
[Install]
WantedBy = multi-user.target