0 امتیاز
66 بازدید
در لینوکس توسط مدیر کل (15.6k امتیاز)

This tutorial is going to show you how to disable IPv6 on Ubuntu. Why do you want to disable IPv6? Although IPv6 is the future, right now many systems and applications still rely on IPv4 and may not work well with IPv6.

For example, if a software repository supports IPv6, then the APT package manager will connect to that repository via IPv6 regardless of whether or not your ISP supports IPv6, as shown in the screenshot below.

disable ipv6 ubuntu

Method 1: Disable IPv6 on Ubuntu via GRUB Boot Loader

This is the easiest method, but it requires you to reboot your computer.

GRUB is the standard boot loader on Linux distributions. Edit the GRUB configuration file with a command-line text editor like Nano.

sudo nano /etc/default/grub

Find the following line.

GRUB_CMDLINE_LINUX=""

Change it to:

GRUB_CMDLINE_LINUX="ipv6.disable=1"

Disable IPv6 on Ubuntu via GRUB Boot Loader

Save and close the file. (Press Ctrl+O, then press Enter to save a file in Nano text editor. Next, press Ctrl+X to exit.)

Update GRUB boot menu.

sudo update-grub

And reboot your computer.

sudo shutdown -r now

Method 2: Disable IPv6 on Ubuntu via sysctl

You can disable IPv6 on your Ubuntu Linux system by making some changes to Linux kernel parameter.

Instead of the editing the /etc/sysctl.conf file, we create a custom config file (60-custom.conf) so the changes can be preserved when you upgrade Ubuntu.

sudo nano /etc/sysctl.d/60-custom.conf

Copy and paste the following 3 lines to this file.

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1

If your computer has a wireless card, you also need to add the following line to the file. Replace wlan0 with the name of your own wireless network interface.

net.ipv6.conf.wlan0.disable_ipv6 = 1

Save and close the file. Then execute the following commands to apply the above changes.

sudo sysctl -p

sudo systemctl restart procps

Now run the following command. You should see 1, which means IPv6 has been successfully disabled.

cat /proc/sys/net/ipv6/conf/all/disable_ipv6

disable ipv6 on ubuntu 16.04

Parameters defined in 60-custom.conf file is preserved across reboot, so IPv6 won’t be enabled next time you boot up Ubuntu unless you manually re-enable it.

To re-enable IPv6 on Ubuntu, simply remove those 3 lines in 60-custom.conf file and run sudo sysctl -p command to load the changes.

Disable IPv6 in Netplan

If you run an Ubuntu server and your network interface is configured with Netplan, then you also need to disable IPv6 in the Netplan configuration file. For example, I set up my Wi-Fi connection from the command line in the /etc/netplan/10-wifi.yaml file. I need to add link-local: [ ipv4 ] to the file, so Netplan will enable only IPv4 for my wireless interface.

ubuntu disable ipv6 in netplan

Run the following command after making changes to Netplan config files.

sudo netplan apply

Disable IPv6 in NetworkManager

If you use Ubuntu desktop, then when your computer resumes from suspend, NetworkManager will reconnect your computer to the router, and it can give your computer an IPv6 address. So we also need to disable IPv6 in NetworkManager. It’s very simple. Go to your network settings, choose the IPv6 tab and disable IPv6.

disable ipv6 in network manager

Click the Apply button. Then restart Network Manager with the following command.

sudo systemctl restart NetworkManager

Disable IPv6 in APT

Sometimes, you need to disable IPv6 in the APT package manage only and other programs can continue to use IPv6 if needed. To disable IPv6 in APT, run the following command to create a configuration file for APT.

sudo nano /etc/apt/apt.conf.d/99force-ipv4

Copy and paste the following line into the file.

Acquire::ForceIPv4 "true";

Save and close the file. From now on, APT will use IPv4 only.

پاسخ شما

حریم شخصی : آدرس ایمیل شما محفوظ میماند و برای استفاده های تجاری و تبلیغاتی به کار نمی رود
FOXNET محلی برای دانستن واشتراک مطالبی که نمی دانستید

سوالات مشابه

0 امتیاز
0 پاسخ 649 بازدید
سوال شده نوامبر 21, 2017 در لینوکس توسط admin مدیر کل (15.6k امتیاز)
0 امتیاز
0 پاسخ 348 بازدید
سوال شده ژوئن 22, 2016 در لینوکس توسط admin مدیر کل (15.6k امتیاز)
0 امتیاز
0 پاسخ 293 بازدید
سوال شده اکتبر 1, 2015 در لینوکس توسط admin مدیر کل (15.6k امتیاز)
0 امتیاز
0 پاسخ 654 بازدید
سوال شده اوت 16, 2017 در ویندوز توسط admin مدیر کل (15.6k امتیاز)
0 امتیاز
0 پاسخ 387 بازدید
سوال شده اوت 25, 2016 در لینوکس توسط admin مدیر کل (15.6k امتیاز)
...