Debian Linux Disable IPv6 Networking

by on July 22, 2010 · 9 comments· LAST UPDATED July 22, 2010

in

How do I disable an IPv6 network connection and all its subsystem for my server? I'm having some problem with my GUI program under Debian "Squeeze", how can I disable IPv6?

The Internet Protocol version 6 can be disabled by removing kernel driver or module called ipv6. To disable the same just type the following command:
echo 'blacklist ipv6' >> /etc/modprobe.d/blacklist
Simply reboot the box:
# reboot

Alternatively you can use the ifconfig command to remove all ipv6 addressed assigned to your box. You also need to remove ipv6 gateway using the route command itself and finally use the rmmod command to remove ipv6 driver. This is useful if you don't want to reboot the box. Please note that eth0 connectivity will go down and you cannnot use the following commands over the ssh session:
# ifconfig down eth0
# route -A inet6 del {network6}/{prefixlength} gw {ipv6address} eth0
# lsmod | grep ipv6
# rmmod ipv6
# ifconfig eth0 up
#### or
# /etc/init.d/networking restart

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 9 comments… read them below or add one }

1 Jack Wade July 26, 2010 at 3:32 am

Just as ipv6 is starting to gain adoption…

Reply

2 socrates August 18, 2010 at 12:17 pm

i will have one linux packup in cd

Reply

3 ToxiNiK February 22, 2011 at 1:05 pm

How to turn off IPv6 In squeeze?
Disable ipv6 in kernel:
# echo net.ipv6.conf.all.disable_ipv6=1 > /etc/sysctl.d/disableipv6.conf
will disable ipv6 at next reboot.

Reply

4 tuxy42 June 2, 2011 at 3:15 pm

Congrats! according me this is the cleaner way to do this! Thanks!

Reply

5 johnlth93 June 17, 2013 at 6:51 am

You can also do this

echo ’1′ > /proc/sys/net/ipv6/conf/all/disable_ipv6

just saying

Reply

6 penguintamer July 22, 2013 at 1:11 pm

Instead of rebooting after adding the disableipv6.conf file, just run:
# sysctl -w net.ipv6.conf.all.disable_ipv6=1

This will make the change take effect immediately.

Reply

7 Penny April 12, 2011 at 7:08 pm

Hi.

Debian Testing amd 64:
Question: How to disable ‘All’ programs ability to listen using tcp6.
i.e netstat -tupln
tcp 0 0 0.0.0.0:3142 0.0.0.0:* LISTEN 1787/apt-cacher-ng
tcp6 0 0 :::3142 :::* LISTEN 1787/apt-cacher-ng

Steps taken:
1. Added to /etc/modprobe.d/blacklist.conf : ‬blacklist ipv6‭
2. Created: /etc/sysctl.d/disable-ipv6.conf ;
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.eth1.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.vboxnet0.disable_ipv6 = 1
3. Uncommented: /etc/sysctl.conf ;
net.ipv6.conf.all.accept_redirects = 0
net.ipv6.conf.all.accept_source_route = 0
4. Added: /etc/modprobe.d/aliases.conf
alias net-pf-10 off
alias ivp6 off
5. Commented out: /etc/hosts (all ipv6 references)

I wish to disallow any and all ipv6 initiated by a program.

Caveats: Unfortunately using the firewall ‘ufw’ overrides the /etc/sysctl.conf and /etc/sysctl.d/* . To include my custom options.
I added the below to: /etc/ufw/sysctl.conf ;

net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
net.ipv6.conf.eth1.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.vboxnet0.disable_ipv6 = 1

Still showing ipv6 listenting. (grrrr)

Thank you.
Penny

Reply

8 Tom July 6, 2013 at 9:15 pm

How to enable if needed?

Thanks :)

Reply

9 johnlth93 July 7, 2013 at 7:17 pm

Only if you got native ipv6 connection.

Reply

Leave a Comment

Tagged as: , , , , , , , , , ,

Previous Faq:

Next Faq: