Linux – How to Disable IPv6 on a Specific Interface

ipv6linuxnetworkingscript

Could someone tell me how to disable ipv6 auto-config on a specific network interface in CentOS?

The current situation is:

A PC has two network adapters eth0 and eth1 that are connecting to the same LAN, in which, IPv6 router is advertising an IPv6 prefix with NDRA (Neighbor Discovery Router Advertisements) packet. As a result, both eth0 and eth1 are configuring the IPv6 address with that prefix automatically.

But, I just want to enable ipv6 on eth1 and disable it on eth0. I've tried the following methods, but they don't work.

1. /etc/sysconfig/network

NETWORKING_IPV6=no
IPV6_AUTOCONF=no

This will disable ipv6 on both eth0 and eth1.

2. /etc/sysconfig/network-scripts/ifcfg-eth0

IPV6INIT=no
IPV6_AUTOCONF=no

Then, it doesn't work. I have restarted the network service already. I am a little confused about this issue. Thanks in advanced.

Best Answer

You can disable it from /etc/sysctl.conf with this line:

net.ipv6.conf.eth0.disable_ipv6 = 1

Take a look at /proc/sys/net/ipv6/conf/eth0. There are many options you can set in that directory, like leaving IPv6 enabled but disabling autoconf etc.

Related Question