{"id":2224,"date":"2026-03-24T02:47:03","date_gmt":"2026-03-23T23:47:03","guid":{"rendered":"https:\/\/computingforgeeks.com\/?p=2224"},"modified":"2026-03-24T15:15:11","modified_gmt":"2026-03-24T12:15:11","slug":"disable-ipv6-linux","status":"publish","type":"post","link":"https:\/\/computingforgeeks.com\/disable-ipv6-linux\/","title":{"rendered":"How to Disable IPv6 on Linux (Ubuntu, Rocky, Debian)"},"content":{"rendered":"\n<p>Most Linux distributions ship with IPv6 enabled by default. That works fine until it does not. Legacy applications that choke on IPv6 addresses, VPN tunnels that only handle IPv4, or troubleshooting scenarios where you need a clean IPv4-only stack that don&#8217;t handle dual-stack networking, troubleshooting DNS resolution issues, or hardening a server that only needs IPv4 connectivity. This guide covers every method to disable IPv6 on Ubuntu 24.04\/22.04 and Rocky Linux 10\/AlmaLinux 10, from temporary runtime changes to permanent kernel-level configuration.<\/p>\n\n\n\n<p>Each method has trade-offs. Runtime sysctl changes are instant but lost on reboot. Persistent sysctl files survive reboots but can be overridden by NetworkManager. GRUB kernel parameters are the most bulletproof approach since IPv6 never loads in the first place. Pick the method that fits your use case.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Prerequisites<\/h2>\n\n\n\n<p>You need root or sudo access on your Linux system. These instructions are tested on:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li>Ubuntu 24.04 LTS and Ubuntu 22.04 LTS<\/li>\n<li>Rocky Linux 10 and AlmaLinux 10<\/li>\n<\/ul>\n\n\n\n<p>The commands work on other distributions in the same families (Debian 13\/12, RHEL 10, Fedora 42) with no changes.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Check Current IPv6 Status<\/h2>\n\n\n\n<p>Before making changes, confirm whether IPv6 is currently active on your system. Run this command to check the kernel parameter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/sys\/net\/ipv6\/conf\/all\/disable_ipv6<\/code><\/pre>\n\n\n\n<p>A value of <code>0<\/code> means IPv6 is enabled. A value of <code>1<\/code> means it is disabled.<\/p>\n\n\n\n<p>You can also check for active IPv6 addresses on your interfaces:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ip -6 addr show<\/code><\/pre>\n\n\n\n<p>If you see <code>inet6<\/code> addresses listed (other than <code>::1<\/code> on loopback), IPv6 is active and in use.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 1: Disable IPv6 Temporarily with sysctl (Runtime Only)<\/h2>\n\n\n\n<p>This method disables IPv6 immediately without a reboot, but the change is lost when the system restarts. It is useful for quick testing or troubleshooting.<\/p>\n\n\n\n<p>Disable IPv6 on all network interfaces:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl -w net.ipv6.conf.all.disable_ipv6=1\nsudo sysctl -w net.ipv6.conf.default.disable_ipv6=1<\/code><\/pre>\n\n\n\n<p>The kernel applies the change instantly. Verify it took effect:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/sys\/net\/ipv6\/conf\/all\/disable_ipv6<\/code><\/pre>\n\n\n\n<p>The output should show <code>1<\/code>, confirming IPv6 is now disabled.<\/p>\n\n\n\n<p>You can also confirm no IPv6 addresses remain on your interfaces:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ip -6 addr show<\/code><\/pre>\n\n\n\n<p>This should return empty output or only show the loopback address. Remember, this change reverts after a reboot. For a persistent solution, use Method 2 or Method 3.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 2: Disable IPv6 Permanently via sysctl Configuration<\/h2>\n\n\n\n<p>Creating a sysctl configuration file makes the IPv6 disable setting persist across reboots. This is the most common approach for servers that need IPv4 only.<\/p>\n\n\n\n<p>Create a new sysctl configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/sysctl.d\/70-disable-ipv6.conf<\/code><\/pre>\n\n\n\n<p>Add the following lines:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>net.ipv6.conf.all.disable_ipv6 = 1\nnet.ipv6.conf.default.disable_ipv6 = 1\nnet.ipv6.conf.lo.disable_ipv6 = 1<\/code><\/pre>\n\n\n\n<p>Save the file and apply the settings without rebooting:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl --system<\/code><\/pre>\n\n\n\n<p>You should see your settings being applied in the output. Verify the change:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysctl net.ipv6.conf.all.disable_ipv6<\/code><\/pre>\n\n\n\n<p>The output should confirm the value is set to <code>1<\/code>:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>net.ipv6.conf.all.disable_ipv6 = 1<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Important note for NetworkManager systems<\/h3>\n\n\n\n<p>On systems running NetworkManager (default on Rocky Linux 10, AlmaLinux 10, and Ubuntu desktop), NetworkManager can re-enable IPv6 on managed interfaces even after setting the sysctl parameter. To prevent this, also disable IPv6 in NetworkManager for each connection.<\/p>\n\n\n\n<p>List your active connections:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nmcli connection show --active<\/code><\/pre>\n\n\n\n<p>Then disable IPv6 on the connection (replace <code>ens18<\/code> with your actual connection name):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nmcli connection modify ens18 ipv6.method disabled\nsudo nmcli connection up ens18<\/code><\/pre>\n\n\n\n<p>This ensures NetworkManager won&#8217;t override your sysctl settings.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 3: Disable IPv6 via GRUB Kernel Parameter<\/h2>\n\n\n\n<p>The most reliable way to disable IPv6 is at the kernel level through GRUB boot parameters. This prevents the IPv6 kernel module from loading entirely, which means no process or service can re-enable it at runtime.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Ubuntu 24.04\/22.04<\/h3>\n\n\n\n<p>Edit the GRUB configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/default\/grub<\/code><\/pre>\n\n\n\n<p>Find the line starting with <code>GRUB_CMDLINE_LINUX<\/code> and add the IPv6 disable parameter. If the line already has values, append to them:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GRUB_CMDLINE_LINUX=\"ipv6.disable=1\"<\/code><\/pre>\n\n\n\n<p>If you have existing parameters, keep them and add <code>ipv6.disable=1<\/code> at the end, separated by a space.<\/p>\n\n\n\n<p>Regenerate the GRUB configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-grub<\/code><\/pre>\n\n\n\n<p>Reboot the system for the change to take effect:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo reboot<\/code><\/pre>\n\n\n\n<h3 class=\"wp-block-heading\">Rocky Linux 10 \/ AlmaLinux 10<\/h3>\n\n\n\n<p>On RHEL-family distributions, edit the GRUB defaults:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/default\/grub<\/code><\/pre>\n\n\n\n<p>Add <code>ipv6.disable=1<\/code> to the <code>GRUB_CMDLINE_LINUX<\/code> line:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>GRUB_CMDLINE_LINUX=\"crashkernel=auto ipv6.disable=1\"<\/code><\/pre>\n\n\n\n<p>Keep any existing parameters and append the IPv6 disable flag. Then regenerate the GRUB configuration. The command differs depending on your boot mode.<\/p>\n\n\n\n<p>For BIOS-based systems:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/code><\/pre>\n\n\n\n<p>For UEFI-based systems:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo grub2-mkconfig -o \/boot\/efi\/EFI\/rocky\/grub.cfg<\/code><\/pre>\n\n\n\n<p>On AlmaLinux 10, replace <code>rocky<\/code> with <code>almalinux<\/code> in the UEFI path. Then reboot:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo reboot<\/code><\/pre>\n\n\n\n<p>After the reboot, verify the kernel parameter was applied:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/cmdline<\/code><\/pre>\n\n\n\n<p>You should see <code>ipv6.disable=1<\/code> in the output. This confirms IPv6 is disabled at the kernel level.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Method 4: Disable IPv6 on a Specific Network Interface<\/h2>\n\n\n\n<p>Sometimes you only need to disable IPv6 on one interface while keeping it active on others. This is common on multi-homed servers where the internal interface should be IPv4-only but the external interface needs IPv6.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using sysctl for a single interface<\/h3>\n\n\n\n<p>To disable IPv6 on a specific interface at runtime (replace <code>ens18<\/code> with your interface name):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl -w net.ipv6.conf.ens18.disable_ipv6=1<\/code><\/pre>\n\n\n\n<p>To make this persistent, create a sysctl configuration file:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo vi \/etc\/sysctl.d\/70-disable-ipv6-ens18.conf<\/code><\/pre>\n\n\n\n<p>Add the following line (adjust the interface name as needed):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>net.ipv6.conf.ens18.disable_ipv6 = 1<\/code><\/pre>\n\n\n\n<p>Apply the configuration:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl --system<\/code><\/pre>\n\n\n\n<p>Verify IPv6 is disabled only on that interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ip -6 addr show dev ens18<\/code><\/pre>\n\n\n\n<p>This should return no IPv6 addresses for <code>ens18<\/code>, while other interfaces retain their IPv6 configuration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Using NetworkManager for a single interface<\/h3>\n\n\n\n<p>On systems with NetworkManager, you can disable IPv6 per connection profile:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nmcli connection modify ens18 ipv6.method disabled\nsudo nmcli connection up ens18<\/code><\/pre>\n\n\n\n<p>Confirm the change by checking the connection details:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>nmcli connection show ens18 | grep ipv6.method<\/code><\/pre>\n\n\n\n<p>The output should show <code>ipv6.method: disabled<\/code>.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">How to Re-enable IPv6<\/h2>\n\n\n\n<p>If you need to restore IPv6 after disabling it, reverse the steps from whichever method you used.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Re-enable after sysctl (runtime)<\/h3>\n\n\n\n<p>Set the disable parameter back to 0:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo sysctl -w net.ipv6.conf.all.disable_ipv6=0\nsudo sysctl -w net.ipv6.conf.default.disable_ipv6=0<\/code><\/pre>\n\n\n\n<p>IPv6 addresses will reappear on your interfaces within seconds.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Re-enable after persistent sysctl file<\/h3>\n\n\n\n<p>Remove the configuration file you created:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo rm \/etc\/sysctl.d\/70-disable-ipv6.conf\nsudo sysctl --system<\/code><\/pre>\n\n\n\n<p>If you also disabled IPv6 in NetworkManager, re-enable it:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo nmcli connection modify ens18 ipv6.method auto\nsudo nmcli connection up ens18<\/code><\/pre>\n\n\n\n<p>The interface will obtain an IPv6 address through SLAAC or DHCPv6, depending on your network configuration.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Re-enable after GRUB kernel parameter<\/h3>\n\n\n\n<p>Edit <code>\/etc\/default\/grub<\/code> and remove <code>ipv6.disable=1<\/code> from the <code>GRUB_CMDLINE_LINUX<\/code> line. Then regenerate the GRUB configuration.<\/p>\n\n\n\n<p>On Ubuntu:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo update-grub<\/code><\/pre>\n\n\n\n<p>On Rocky Linux \/ AlmaLinux (BIOS):<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sudo grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/code><\/pre>\n\n\n\n<p>Reboot for the change to take effect. After reboot, IPv6 will be fully functional again.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Verify IPv6 is Disabled<\/h2>\n\n\n\n<p>Regardless of which method you used, run these checks to confirm IPv6 is properly disabled.<\/p>\n\n\n\n<p>Check the kernel parameter value:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>sysctl net.ipv6.conf.all.disable_ipv6<\/code><\/pre>\n\n\n\n<p>A value of <code>1<\/code> confirms IPv6 is disabled system-wide.<\/p>\n\n\n\n<p>Confirm no IPv6 addresses are assigned to any interface:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ip -6 addr show<\/code><\/pre>\n\n\n\n<p>This should return empty output when IPv6 is fully disabled.<\/p>\n\n\n\n<p>If you used the GRUB method, verify the kernel boot parameter:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>cat \/proc\/cmdline | grep ipv6<\/code><\/pre>\n\n\n\n<p>You should see <code>ipv6.disable=1<\/code> in the kernel command line.<\/p>\n\n\n\n<p>Test that IPv6 connectivity is actually gone by attempting a connection to an IPv6-only endpoint:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>ping -6 -c 2 ::1<\/code><\/pre>\n\n\n\n<p>With IPv6 disabled, this command will fail with &#8220;connect: Network is unreachable&#8221; or a similar error.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\">Things to Watch Out For<\/h2>\n\n\n\n<p>Disabling IPv6 can have side effects that catch people off guard. Keep these in mind:<\/p>\n\n\n\n<ul class=\"wp-block-list\">\n<li><strong>SSH may slow down<\/strong> &#8211; If your SSH config or DNS returns AAAA records, SSH will try IPv6 first and wait for it to time out. Add <code>AddressFamily inet<\/code> to <code>\/etc\/ssh\/sshd_config<\/code> to force IPv4-only connections.<\/li>\n<li><strong>DNS resolution issues<\/strong> &#8211; Some resolvers query for AAAA records even when IPv6 is disabled. If you see slow DNS lookups, configure your resolver to prefer IPv4.<\/li>\n<li><strong>Package managers<\/strong> &#8211; APT and DNF may try IPv6 mirrors if the mirror list includes AAAA records. This usually falls back to IPv4 automatically but adds latency.<\/li>\n<li><strong>Docker and containers<\/strong> &#8211; Docker uses IPv6 internally for some bridge networking features. Disabling IPv6 on the host can affect container networking. Test thoroughly before applying to production container hosts.<\/li>\n<li><strong>Localhost connections<\/strong> &#8211; Some applications bind to <code>::1<\/code> (IPv6 localhost) by default. With IPv6 disabled, those applications need to be configured to bind to <code>127.0.0.1<\/code> instead.<\/li>\n<li><strong>NetworkManager overrides<\/strong> &#8211; On RHEL-family systems, NetworkManager can re-enable IPv6 on managed interfaces. Always disable IPv6 in both sysctl and NetworkManager to avoid conflicts.<\/li>\n<\/ul>\n\n\n\n<h2 class=\"wp-block-heading\">Frequently Asked Questions<\/h2>\n\n\n\n<h3 class=\"wp-block-heading\">Is it safe to disable IPv6 on a production server?<\/h3>\n\n\n\n<p>Yes, as long as your applications and services don&#8217;t depend on IPv6 connectivity. Most server workloads still run on IPv4. Check that your application configs don&#8217;t bind to IPv6 addresses before disabling it.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Which method is best for servers?<\/h3>\n\n\n\n<p>The GRUB kernel parameter method (Method 3) is the most reliable for production servers. It prevents the IPv6 stack from loading entirely, so no service or process can re-enable it. The sysctl file method (Method 2) is a close second and doesn&#8217;t require a reboot to apply.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Will disabling IPv6 break my system?<\/h3>\n\n\n\n<p>Modern Linux distributions work fine without IPv6. The main risks are applications that bind exclusively to IPv6 addresses and SSH slowdowns if DNS returns AAAA records. Both are easy to fix with minor configuration changes.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Can I disable IPv6 on one interface and keep it on another?<\/h3>\n\n\n\n<p>Yes, Method 4 covers exactly this. Use the per-interface sysctl parameter or NetworkManager&#8217;s per-connection setting to selectively disable IPv6 on specific interfaces.<\/p>\n\n","protected":false},"excerpt":{"rendered":"<p>Most Linux distributions ship with IPv6 enabled by default. That works fine until it does not. Legacy applications that choke on IPv6 addresses, VPN tunnels that only handle IPv4, or troubleshooting scenarios where you need a clean IPv4-only stack that don&#8217;t handle dual-stack networking, troubleshooting DNS resolution issues, or hardening a server that only needs &#8230; <a title=\"How to Disable IPv6 on Linux (Ubuntu, Rocky, Debian)\" class=\"read-more\" href=\"https:\/\/computingforgeeks.com\/disable-ipv6-linux\/\" aria-label=\"Read more about How to Disable IPv6 on Linux (Ubuntu, Rocky, Debian)\">Read more<\/a><\/p>\n","protected":false},"author":3,"featured_media":2225,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[299,50,55],"tags":[36537,390,36538],"class_list":["post-2224","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-how-to","category-linux-tutorials","category-networking","tag-disable-ipv6-on-linux","tag-ipv6","tag-ipv6-on-linux"],"_links":{"self":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/2224","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/users\/3"}],"replies":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/comments?post=2224"}],"version-history":[{"count":2,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/2224\/revisions"}],"predecessor-version":[{"id":164106,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/posts\/2224\/revisions\/164106"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media\/2225"}],"wp:attachment":[{"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/media?parent=2224"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/categories?post=2224"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/computingforgeeks.com\/wp-json\/wp\/v2\/tags?post=2224"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}