Disable IPv6 from the command line on a Macbook

Run a command through the Terminal app:

  • Open Launchpad.
  • Search for Terminal.
  • Click on the Terminal.app.
  • If your active network is WiFi enter the following command:
networksetup -setv6off Wi-Fi
  • If you are on Ethernet:
networksetup -setv6off Ethernet

To re-enable IPv6, you need to replace setv6off to setv6automatic for Wi-Fi or Ethernet:

networksetup -setv6automatic Wi-Fi 
networksetup -setv6automatic Ethernet

Temporarily Force Ubuntu to IPV4

Refer: https://linuxconfig.org/how-to-disable-ipv6-address-on-ubuntu-20-04-lts-focal-fossa

sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1
sudo sysctl -w net.ipv6.conf.default.disable_ipv6=1

The above commands will temporarily disable IPv6, meaning that the settings will not persist after reboot. To re-enable IPv6 reboot your system or execute the above commands again however reverse the logic and change 1 to 0

In case you need more permanent solution to disable IPv6 even after system reboot follow the steps below:

As an administrative user open up the /etc/default/grub file using your favourite text editor and make to following changes:

FROM:
GRUB_CMDLINE_LINUX_DEFAULT=""
TO:
GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"

Once ready update Grub menu:

sudo update-grub

In case you need to re-enable the IPv6 network addresses simply remove the ipv6.disable=1 from the /etc/default/grub file and run the update-grub command.