• Skip to primary navigation
  • Skip to content
  • Skip to primary sidebar

The Geek Diary

HowTos | Basics | Concepts

  • Solaris
    • Solaris 11
    • SVM
    • ZFS
    • Zones
    • LDOMs
    • Hardware
  • Linux
    • CentOS/RHEL 7
    • RHCSA notes
    • SuSE Linux Enterprise
    • Linux Services
  • VCS
    • VxVM
  • Interview Questions
  • oracle
    • ASM
    • mysql
    • RAC
    • oracle 12c
    • Data Guard
  • DevOps
    • Docker
    • Shell Scripting
  • Hadoop
    • Hortonworks HDP
      • HDPCA
    • Cloudera
      • CCA 131

How to disable or enable the IPv6 protocol in CentOS/RHEL 6

By admin

Red Hat Enterprise Linux enables Internet Protocol Version 6 (IPv6) by default. However, in certain situations, some users may find it desirable to disable IPv6 support or to re-enable it after it has been disabled.

Disabling IPv6 support in CentOS/RHEL 6

1. Disabling the ipv6 module itself

1. Create a file /etc/modprobe.d/ipv6.conf with the following contents:

# vi /etc/modprobe.d/ipv6.conf
options ipv6 disable=1

2. Disable the ip6tables service from starting at boot by issuing the following command:

# chkconfig ip6tables off

3. Reboot the system.

# shutdown -r now

2. Disabled via the /etc/sysctl.conf

Alternatively, this can be done via sysctl settings. disaling ipv6 using sysctl will ensure ipv6 isn’t used even if the ipv6 module is loaded and can work as a short term solution (until a full reboot). Only disables (unhooks all of the calls) for the ipv6 module, but doesn’t prevent it from loading.

1. Append the following to the end of the /etc/sysctl.conf configuration file:

# IPv6 support in the kernel, set to 0 by default
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1

2. Comment out any IPv6 addresses found in /etc/hosts, including ::1 localhost address:

# cp -p /etc/hosts /etc/hosts.disableipv6
# sed -i 's/^[[:space:]]*::/#::/' /etc/hosts
Note: Optionally to prevent rpc.nfsd setting up IPv6 sockets while NFS server is running, Edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “v” in the third column to “-“(hyphen/dash).

3. Prevent the module from loading (not recommended)

Unloading the module is not recommended due to the dependency factors it has with other modules (for example: bonding), selinux denials associated with dynamically requesting the ipv6 module functionality, and services that will require the module to be loaded.

1. Modify /etc/modprobe.d/ipv6.conf with the following contents:

# vi /etc/modprobe.d/ipv6.conf
install ipv6 /bin/true

2. Restart the system.

# shutdown -r now

Re-enabling IPv6 support in CentOS/RHEL 6

1. Review the files under /etc/modprobe.d/ and remove (or comment out) of the following lines if any of them is present:

options ipv6 disable=1
install ipv6 /bin/true
blacklist ipv6
alias ipv6 off

2. Configure the ip6tables service to start at boot by issuing the following command:

# chkconfig ip6tables on

3. Make sure the following options to your /etc/sysctl.conf are set to default value ‘0‘

# vi /etc/sysctl.conf
# ipv6 support in the kernel, set to 0 by default
net.ipv6.conf.all.disable_ipv6 = 0
net.ipv6.conf.default.disable_ipv6 = 0

4. Make sure the following line exists in /etc/hosts and is not commented out:

# vi /etc/hosts
::1         localhost localhost.localdomain localhost6 localhost6.localdomain6

5. Edit /etc/netconfig for the lines starting with udp6 and tcp6; change the “-“(hyphen/dash) in the third column to “v”

6. Reboot the system to activate IPv6 support.

# shutdown -r now
How to disable or enable the IPv6 protocol in CentOS/RHEL 7
How to disable or enable the IPv6 protocol in CentOS/RHEL 5
How to disable or enable the IPv6 protocol in CentOS/RHEL 4

Filed Under: CentOS/RHEL 6, Fedora, Linux

Some more articles you might also be interested in …

  1. How to use “btrfs scrub” command to manage scrubbing on Btrfs file systems
  2. How to monitor the Mounting/Umounting of Mount Points Using Auditd on CentOS/RHEL 6,7
  3. CentOS / RHEL : How to delete LUKS encrypted device
  4. Linux OS Service ‘rpcidmapd’
  5. Defining System Jobs Using Cron under Linux
  6. How to Create a User with nologin shell (/sbin/nologin) in Linux
  7. How to Copy / Move Files and Directories in Linux with “cp” and “mv” commands
  8. CentOS / RHEL : How To Check FC Brocade HBA Firmware
  9. lvdisplay error: “Failed to create directory /var/lock/lvm. File-based locking initilisation failed.”
  10. How to turn-off auto fsck in Linux

You May Also Like

Primary Sidebar

Recent Posts

  • How to set the order to load certain modules in CentOS/RHEL 7 and 8
  • How to configure initrd / initramfs to including kernel modules in CentOS/RHEL
  • How to configure systemd.path to trigger an event when any changes made to a directory
  • Script to monitor RMAN Backup and Restore Operations
  • Oracle RMAN Backup Shell Script Example
  • Archives
  • Contact Us
  • Copyright

© 2019 · The Geek Diary