How to Disable IPv6 on Linux

How to Disable Ipv6 on Linux

How to Disable IPv6 on Linux

Home » News » How to Disable IPv6 on Linux
Table of Contents

IPv6 presents a a lot bigger addressing scheme than IPv4, which is among the many causes it was developed. Nonetheless, I’ve seen uncommon situations wherein IPv6 has brought about community issues.

Since some {hardware} doesn’t make the most of IPv6 (and a few admins is likely to be working with IPv4), a short lived and simple resolution is to disable IPv6. The protocol could be re-enabled when the difficulty has been completely resolved.

When you’ve got {hardware} that completely implements IPv6 and software program that makes use of it accurately, this can be a non-issue. However in the event you’re having networking points with Linux servers or desktops, and also you’ve exhausted all potential areas, you would possibly attempt disabling v6 of the community protocol.

I’ve had just a few situations the place communication between a Linux desktop and an previous router would continually drop, and disabling IPv6 was the one resolution that labored. After some time, I’d re-enable IPv6 to see if a router firmware replace (and a desktop OS replace) had solved the issue. In some situations, it solved the difficulty, and IPv6 might stay enabled, although in different situations, IPv6 must be disabled once more.

I’ll present you easy methods to disable IPv6 on a Linux machine. (Be aware: I like to recommend disabling IPv6 solely whenever you’ve exhausted all different choices. Additionally, it is best to think about this a short lived repair.)

SEE: High Instructions Linux Admins Must Know (roosho Premium)

Command line

You guessed it: We’re going to be working with the command line. I’ll present you easy methods to disable IPv6 on Crimson Hat- and Debian-based distributions.

Right here’s easy methods to disable the protocol on a Crimson Hat-based system:

  1. Open a terminal window.
  2. Change to the foundation consumer.
  3. Concern the command sysctl -w web.ipv6.conf.all.disable_ipv6=1
  4. Concern the command sysctl -w web.ipv6.conf.default.disable_ipv6=1

To re-enable IPv6, problem the next instructions:

sysctl -w web.ipv6.conf.all.disable_ipv6=0

sysctl -w web.ipv6.conf.default.disable_ipv6=0

Right here’s easy methods to disable the protocol on a Debian-based machine.

  1. Open a terminal window.
  2. Concern the command sudo nano /and so on/sysctl.conf
  3. Add the next on the backside of the file:

web.ipv6.conf.all.disable_ipv6 = 1

web.ipv6.conf.default.disable_ipv6 = 1

web.ipv6.conf.lo.disable_ipv6 = 1

  1. Save and shut the file.
  2. Reboot the machine.

To re-enable IPv6, take away the above strains from /and so on/sysctl.conf and reboot the machine.

SEE: Tips on how to View Your SSH Keys in Linux, macOS, and Home windows (roosho)

The caveats

For those who occur to make use of X Forwarding via ssh, disabling IPv6 can break this method. To repair that problem, it’s essential to open the /and so on/ssh/sshd_config file and alter the #AddressFamily any to AddressFamily inet. Save that file and restart sshd.

For those who use Postfix, you would encounter points with the service beginning. To repair this, you’ll have to make use of an IPv4 loopback. Open the /and so on/postfix/primary.cf file, remark out the localhost line, and add the IPv4 loopback like so:

#inet_interfaces = localhost

inet_interfaces = 127.0.0.1

SEE: Tips on how to Set Momentary Atmosphere Variables in Linux (roosho)

An imperfect resolution

This isn’t an ideal resolution, however generally you should be artistic in troubleshooting. For those who’re encountering odd networking errors with Linux servers and desktops, attempt disabling IPv6 to help you in your troubleshooting or to offer a short lived repair.

This text was initially printed in June 2016. It was up to date by Antony Peyton in January 2025.

author avatar
roosho Senior Engineer (Technical Services)
I am Rakib Raihan RooSho, Jack of all IT Trades. You got it right. Good for nothing. I try a lot of things and fail more than that. That's how I learn. Whenever I succeed, I note that in my cookbook. Eventually, that became my blog. 
share this article.

Enjoying my articles?

Sign up to get new content delivered straight to your inbox.

Please enable JavaScript in your browser to complete this form.
Name