1

I have to disable ipv6 on 100+ servers. Obviously I don't want to edit grub of every server by hand, and don't want to play around with sed or other crazy stuff.

I tried to do this:

mkdir -p /etc/default/grub.d/
echo 'GRUB_CMDLINE_LINUX_DEFAULT="${GRUB_CMDLINE_LINUX_DEFAULT} ipv6.disable=1"' >> /etc/default/grub.d/disable-ipv6.cfg

But now my machine won't boot! I need a proper, clean, portable solution to disable ipv6 on ubuntu 18.04 :(

Freedo
  • 1,205
  • 6
  • 31
  • 57
  • You should also add `update-grub2` for the change to take effect. What you did seems quite all right, plus not applied, can't tell why your machine fails to boot. I suggest pressing `e` on GRUB screen to see the parametres next to `vmlinuz` line. You can edit them of course; if you see `ipv6.disable=1` (although I don't think so, not applied) delete it and try to boot. – Krackout May 28 '21 at 07:39
  • I did run ```sudo update-grub``` but not update-grub2 – Freedo May 28 '21 at 07:42
  • Ok, it's the same. So, try to edit line on GRUB screen, remove `ipv6.disable=1` and boot. At least you'll know if it really produced such a problem if it boots to OS. Then check logs to find out why. Which tool do you intend to use to apply the change, whenever successful, to all the servers? – Krackout May 28 '21 at 07:45
  • I'd just run parallel-ssh to all the servers. I booted into rescue mode and undid the changes and my server boot ok now, but with ipv6. I tried to do the same but run update-grub2 now but still not going online after rebooting – Freedo May 28 '21 at 07:48
  • This is a remote server I connect with ssh and have no physical access – Freedo May 28 '21 at 07:50
  • So, may the logs help you, to find why disabling IPv6 blocks booting. If you locate the issue post it as an answer if you like, I'm curious. Or someone Ubuntu specific may know and share with us. – Krackout May 28 '21 at 07:56
  • I don't know where to find logs for this – Freedo May 28 '21 at 08:00

1 Answers1

0

You can use Ansible to modify all of the machines on your network at the click of a button.

Make it run these commands:

sudo -i
cat <<EOF >>/etc/sysctl.d/99-sysctl.conf
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.wlan0.disable_ipv6 = 1
EOF

sudo sysctl -p

You could also try this.

echo 'GRUB_CMDLINE_LINUX="ipv6.disable=1"' >> /etc/default/grub
Shōgun8
  • 695
  • 5
  • 16
  • I prefer to create a file in my servers that will take care of this but thank you – Freedo May 28 '21 at 22:34
  • Ansible will just use SSH to programmatically upload that file to all the servers on the network; it just effectively enables you to modify all of the servers however you wish at the click if the button. It's the same as logging into each server and modifying the files by hand. It creates an asymmetric bell curve in your work flow. – Shōgun8 May 29 '21 at 01:26
  • this won't fix the issue since I can't even get this file to work in a single machine! – Freedo May 29 '21 at 01:26
  • sysctl doesn't work after reboot, ipv6 is still enabled...I'll ty your echo and see what happens. are you sure it won't cause issue with the grub defaults? – Freedo May 29 '21 at 01:58
  • You can have more than one ***GRUB_CMDLINE_LINUX*** line. See this for details -> https://unix.stackexchange.com/a/440962. – Shōgun8 May 29 '21 at 06:23
  • In short: Options in *GRUB_CMDLINE_LINUX* are always effective. Options in *GRUB_CMDLINE_LINUX_DEFAULT* are effective ONLY during normal boot (NOT during recovery mode). – Shōgun8 May 29 '21 at 06:30
  • It seems even just your echo makes my machine not reachable after rebooting :( – Freedo May 30 '21 at 08:29
  • what does your ***/etc/default/grub*** file looks like after running that command? – Shōgun8 May 30 '21 at 09:47