{"id":7094,"date":"2017-10-12T23:43:42","date_gmt":"2017-10-12T15:43:42","guid":{"rendered":"http:\/\/rmohan.com\/?p=7094"},"modified":"2017-10-12T23:45:22","modified_gmt":"2017-10-12T15:45:22","slug":"disable-or-enable-the-ipv6-protocol","status":"publish","type":"post","link":"https:\/\/mohan.sg\/?p=7094","title":{"rendered":"Disable or enable the IPv6 protocol"},"content":{"rendered":"<p><strong>Disable or enable the IPv6 protocol <\/strong><\/p>\n<p><strong>Disabling IPv6 support in Red Hat Enterprise Linux 7<\/strong><\/p>\n<p>    Disable ipv6 built-in kernel module.<\/p>\n<p>    Edit \/etc\/default\/grub and append ipv6.disable=1 to GRUB_CMDLINE_LINUX like the following sample:<br \/>\n    Raw<\/p>\n<p>    GRUB_CMDLINE_LINUX=&#8221;rd.lvm.lv=rhel\/swap crashkernel=auto rd.lvm.lv=rhel\/root ipv6.disable=1&#8243;<\/p>\n<p>    Run the grub2-mkconfig command to regenerate the grub.cfg file:<br \/>\n    Raw<\/p>\n<p>    # grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/p>\n<p>    Alternatively, on UEFI systems, run the following:<br \/>\n    Raw<\/p>\n<p>    # grub2-mkconfig -o \/boot\/efi\/EFI\/redhat\/grub.cfg<\/p>\n<p>    Reboot the system to disable IPv6 support.<br \/>\n        Note: While following above method if you notice any Selinux denied messages in audit.log file such as avc: denied { module_request } then disable the ipv6 from \/etc\/sysctl.d\/ipv6.conf file shown below instead.<\/p>\n<p>    Alternatively, this can be done via sysctl settings. Please be aware that this breaks SSH Xforwarding unless sshd_config contains AddressFamily inet.<\/p>\n<p>    Create a new file named \/etc\/sysctl.d\/ipv6.conf and add the following options:<br \/>\n    Raw<\/p>\n<p>    # To disable for all interfaces<br \/>\n    net.ipv6.conf.all.disable_ipv6 = 1<br \/>\n    # the protocol can be disabled for specific interfaces as well.<br \/>\n    net.ipv6.conf.<interface>.disable_ipv6 = 1<\/p>\n<p>    The new settings would then need to be reloaded with:<br \/>\n    Raw<\/p>\n<p>    # sysctl -p \/etc\/sysctl.d\/ipv6.conf<\/p>\n<p>    Then rebuild the Initial RAM Disk Image using:<br \/>\n    Raw<\/p>\n<p>    # dracut -f<\/p>\n<p>Optionally to prevent rpc* messages output after disabling ipv6, edit \/etc\/netconfig for the lines starting with udp6 and tcp6; change the &#8220;v&#8221; in the third column to &#8220;-&#8220;(hyphen\/dash). Please refer to rpc* messages output after disabling ipv6.<br \/>\nRe-enabling IPv6 support in Red Hat Enterprise Linux 7<\/p>\n<p>    Edit \/etc\/default\/grub and delete the entry ipv6.disable=1 from the GRUB_CMDLINE_LINUX, like the following sample:<br \/>\n    Raw<\/p>\n<p>    GRUB_CMDLINE_LINUX=&#8221;rd.lvm.lv=rhel\/swap crashkernel=auto rd.lvm.lv=rhel\/root&#8221;<\/p>\n<p>    Run the grub2-mkconfig command to regenerate the grub.cfg file:<br \/>\n    Raw<\/p>\n<p>    # grub2-mkconfig -o \/boot\/grub2\/grub.cfg<\/p>\n<p>    Alternatively, on UEFI systems, run the following:<br \/>\n    Raw<\/p>\n<p>    # grub2-mkconfig -o \/boot\/efi\/EFI\/redhat\/grub.cfg<\/p>\n<p>    Delete the file \/etc\/sysctl.d\/ipv6.conf which contains the entry:<br \/>\n    Raw<\/p>\n<p>    # To disable for all interfaces<br \/>\n    net.ipv6.conf.all.disable_ipv6 = 1<br \/>\n    # the protocol can be disabled for specific interfaces as well.<br \/>\n    net.ipv6.conf.<interface>.disable_ipv6 = 1<\/p>\n<p>    If the Initial RAM Disk image was created earlier while disabling IPv6 , only then carry out this step.<br \/>\n    Raw<\/p>\n<p>    # dracut -f<\/p>\n<p>    Check the content of the file \/etc\/ssh\/sshd_config and make sure the AddressFamily line is commented:<br \/>\n    Raw<\/p>\n<p>    #AddressFamily inet<\/p>\n<p>    Make sure the following line exists in \/etc\/hosts, and is not commented out:<br \/>\n    Raw<\/p>\n<p>    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6<\/p>\n<p>    Reboot the system to enable IPv6 support.<\/p>\n<p>Disabling IPv6 support in Red Hat Enterprise Linux 6<\/p>\n<p>    Create a file \/etc\/modprobe.d\/ipv6.conf with the following contents:<br \/>\n    Raw<\/p>\n<p>    options ipv6 disable=1<\/p>\n<p>    Disable the ip6tables service from starting at boot by issuing the following command:<br \/>\n    Raw<\/p>\n<p>    # chkconfig ip6tables off<\/p>\n<p>    Alternatively, the IPv6 support can also be disabled in the kernel through \/etc\/sysctl.conf by setting following parameter:<br \/>\n    Raw<\/p>\n<p>    # IPv6 support in the kernel, set to 0 by default<br \/>\n    net.ipv6.conf.all.disable_ipv6 = 1<br \/>\n    net.ipv6.conf.default.disable_ipv6 = 1<\/p>\n<p>    Please be aware that this breaks SSH Xforwarding unless AddressFamily inet is set in sshd_config.<\/p>\n<p>    Comment out any IPv6 addresses found in \/etc\/hosts, including ::1 localhost address<br \/>\n    Raw<\/p>\n<p>    # cp -p \/etc\/hosts \/etc\/hosts.disableipv6<br \/>\n    # sed -i &#8216;s\/^[[:space:]]*::\/#::\/&#8217; \/etc\/hosts<\/p>\n<p>    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 &#8220;v&#8221; in the third column to &#8220;-&#8220;(hyphen\/dash)<\/p>\n<p>    Reboot the system to disable IPv6 support.<\/p>\n<p>Note: The solution above only disables (unhooks all of the calls) the ipv6 module, but doesn&#8217;t prevent it from loading. Unloading the module isn&#8217;t recommended due to the dependency factors it has with other modules (for example: bonding) and services. To prevent the module from loading, modify \/etc\/modprobe.d\/ipv6.conf with the following contents:<br \/>\nRaw<\/p>\n<p>install ipv6 \/bin\/true<\/p>\n<p>    Disabling ipv6 in the sysctl.conf will ensure ipv6 isn&#8217;t used even if the ipv6 module is loaded and can work as a short term solution (until a full reboot)<br \/>\n    There is a special case where this might not work, please see The &#8220;ipv6 disable=1&#8221; option does not seem to work on Red Hat Enterprise Linux 6 system.<\/p>\n<p>Re-enabling IPv6 support in Red Hat Enterprise Linux 6<\/p>\n<p>    Review the files under \/etc\/modprobe.d\/ and remove (or comment out) any of the following lines:<br \/>\n    Raw<\/p>\n<p>    options ipv6 disable=1<br \/>\n    install ipv6 \/bin\/true<br \/>\n    blacklist ipv6<br \/>\n    alias ipv6 off<\/p>\n<p>    Configure the ip6tables service to start at boot by issuing the following command:<br \/>\n    Raw<\/p>\n<p>    # chkconfig ip6tables on<\/p>\n<p>    Make sure the following options to your \/etc\/sysctl.conf are set to default value &#8216;0&#8217;<br \/>\n    Raw<\/p>\n<p>    # ipv6 support in the kernel, set to 0 by default<br \/>\n    net.ipv6.conf.all.disable_ipv6 = 0<br \/>\n    net.ipv6.conf.default.disable_ipv6 = 0<\/p>\n<p>    Make sure the following line exists in \/etc\/hosts and is not commented out:<br \/>\n    Raw<\/p>\n<p>    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6<\/p>\n<p>    Edit \/etc\/netconfig for the lines starting with udp6 and tcp6; change the &#8220;-&#8220;(hyphen\/dash) in the third column to &#8220;v&#8221;<\/p>\n<p>    Reboot the system to activate IPv6 support.<\/p>\n<p>Disabling IPv6 support in Red Hat Enterprise Linux 5<\/p>\n<p>    Remove the following line (if present) from the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 ipv6<\/p>\n<p>    Add the following line to the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 off<\/p>\n<p>    In versions of Red Hat Enterprise Linux before 5.4, add the following line to the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias ipv6 off<\/p>\n<p>    In Red Hat Enterprise Linux 5.4 and later, add the following line to the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    options ipv6 disable=1<\/p>\n<p>    To prevent errors during the network initscript start routine, change the NETWORKING_IPV6 parameter in the \/etc\/sysconfig\/network file to the following:<br \/>\n    Raw<\/p>\n<p>    NETWORKING_IPV6=no<\/p>\n<p>    Comment out any IPv6 addresses found in \/etc\/hosts, including ::1 localhost address<br \/>\n    Raw<\/p>\n<p>    # cp -p \/etc\/hosts \/etc\/hosts.disableipv6<br \/>\n    # sed -i &#8216;s\/^[[:space:]]*::\/#::\/&#8217; \/etc\/hosts<\/p>\n<p>    Disable the ip6tables service from starting at boot by issuing the following command:<br \/>\n    Raw<\/p>\n<p>    # chkconfig ip6tables off<\/p>\n<p>    Reboot the system to disable IPv6 support.<\/p>\n<p>Re-enabling IPv6 support in Red Hat Enterprise Linux 5<\/p>\n<p>    Remove the following lines (if present) from the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 off<br \/>\n    alias ipv6 off<br \/>\n    options ipv6 disable=1<\/p>\n<p>    Add the following line to the \/etc\/modprobe.conf file (if not present already):<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 ipv6<\/p>\n<p>    Change the NETWORKING_IPV6 parameter in the \/etc\/sysconfig\/network file to the following:<br \/>\n    Raw<\/p>\n<p>    NETWORKING_IPV6=yes<\/p>\n<p>    Make sure the following line exists in \/etc\/hosts and is not commented out:<br \/>\n    Raw<\/p>\n<p>    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6<\/p>\n<p>    Configure the ip6tables service to start at boot by issuing the following command:<br \/>\n    Raw<\/p>\n<p>    # chkconfig ip6tables on<\/p>\n<p>    Reboot the system to re-enable IPv6 support.<\/p>\n<p>Disabling IPv6 support in Red Hat Enterprise Linux 4<\/p>\n<p>    Remove the following line (if present) from the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 ipv6<\/p>\n<p>    Add the following line to the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 off<\/p>\n<p>    Comment out any IPv6 addresses found in \/etc\/hosts, including ::1 localhost address<br \/>\n    Raw<\/p>\n<p>    # cp -p \/etc\/hosts \/etc\/hosts.disableipv6<br \/>\n    # sed -i &#8216;s\/^[[:space:]]*::\/#::\/&#8217; \/etc\/hosts<\/p>\n<p>    Reboot the system to disable IPv6 support.<\/p>\n<p>Re-enabling IPv6 support in Red Hat Enterprise Linux 4<\/p>\n<p>    Remove the following line from the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 off<\/p>\n<p>    Add the following line to the \/etc\/modprobe.conf file:<br \/>\n    Raw<\/p>\n<p>    alias net-pf-10 ipv6<\/p>\n<p>    Make sure the following line exists in \/etc\/hosts, and is not commented out.<br \/>\n    Raw<\/p>\n<p>    ::1         localhost localhost.localdomain localhost6 localhost6.localdomain6<\/p>\n<p>    Reboot the system to re-enable IPv6 support.<\/p>\n<p>Additional notes<\/p>\n<p>Disabling IPv6 by blacklisting the module invalidates bonding in the system.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Disable or enable the IPv6 protocol <\/p>\n<p>Disabling IPv6 support in Red Hat Enterprise Linux 7<\/p>\n<p> Disable ipv6 built-in kernel module.<\/p>\n<p> Edit \/etc\/default\/grub and append ipv6.disable=1 to GRUB_CMDLINE_LINUX like the following sample: Raw<\/p>\n<p> GRUB_CMDLINE_LINUX=&#8221;rd.lvm.lv=rhel\/swap crashkernel=auto rd.lvm.lv=rhel\/root ipv6.disable=1&#8243;<\/p>\n<p> Run the grub2-mkconfig command to regenerate the grub.cfg file: Raw<\/p>\n<p> # grub2-mkconfig -o [&#8230;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,73],"tags":[],"_links":{"self":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7094"}],"collection":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7094"}],"version-history":[{"count":2,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7094\/revisions"}],"predecessor-version":[{"id":7096,"href":"https:\/\/mohan.sg\/index.php?rest_route=\/wp\/v2\/posts\/7094\/revisions\/7096"}],"wp:attachment":[{"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7094"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7094"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/mohan.sg\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7094"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}