-1

I run a service on IPv4, but sometimes, apparently randomly, it happens that the service uses TCPv6 sockets (I monitor it with ss -s). I want to avoid it, disabling any IPv6 connection.

I tried to disable it putting in /etc/sysctl.conf :

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

and then restarting sysctl sudo sysctl -p. However, it still happens that the service uses IPv6, though it is disabled:

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

The only way I have found to work it out is to put down and up the interface

sudo ifconfig eth1 down
sudo ifconfig eth1 up

Note: no IPv6 address is assigned to any interface. Moreover, I cannot reboot the machine.

Any solution?

2 Answers 2

0

You can disable IPv6 completely from the kernel by editing /etc/default/grub. Find the line:

GRUB_CMDLINE_LINUX_DEFAULT=""

Replace it with:

GRUB_CMDLINE_LINUX_DEFAULT="ipv6.disable=1"

Then run:

update-grub

And reboot.

2
  • Thanks, but I can't reboot the machine.
    – Paolo
    Aug 1, 2015 at 7:59
  • I think you also need net.ipv6.conf.eth1.disable_ipv6 = 1 in sysctl.conf; I would also add all the other known interfaces. You should probably also comment out ::1 in /etc/hosts if you have one...although I doubt this is the source of your problems.
    – o9000
    Aug 1, 2015 at 12:02
0

I am thinking out of the box here because of the no reboot constraint. Maybe if you use some kind of container, docker or lxc for example, for your service allow you to disable ipv6 for the container.

Docker daemon for example has an "--ipv6=true|false" flag

1
  • The point is that I am using a server that is not mine, so I need to be as minimally invasive as possible.I would appreciate a lot if you could address me to a tutorial or guide for implementing your suggestion.
    – Paolo
    Aug 2, 2015 at 19:18

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .