Disable IPv6

From Notes to self
Revision as of 21:39, 12 May 2023 by Verbovet (talk | contribs)
Jump to navigation Jump to search
  • The kernel option ipv6.disable=1 disables the whole IPv6 stack
  • If using the kernel option is not possible, add the following parameters to /etc/sysctl.conf:
# Disable IPv6
net.ipv6.conf.all.disable_ipv6 = 1
net.ipv6.conf.default.disable_ipv6 = 1
net.ipv6.conf.lo.disable_ipv6 = 1
net.ipv6.conf.eth0.disable_ipv6 = 1
...

to prevent configuration of IPv6 for listed interfaces.

  • To configure glibc to prefer ipv4 over ipv6 create /etc/gai.conf:
# Always prefer IPv4 connections
precedence ::ffff:0:0/96  100
  • Getting chrony to not use IPv6 create/edit /etc/default/chrony:
CHRONYD_ARGS="-4"
  • To force ntpd to not use IPv6 add -4 to the options of ntpd in the finction ntpd_start in /etc/rc.d/rc.ntpd
Also comment out 2 lines in /etc/ntp.conf:
#restrict -6 default limited kod nomodify notrap nopeer noquery
#restrict ::1
  • To force sshd to listen IPv4 only add
AddressFamily inet

to /etc/ssh/sshd_config

  • To force httpd to listen IPv4 only, specify an IPv4 address on all Listen directives, for example,
Listen 0.0.0.0:80

(in /etc/httpd/httpd.conf and/or /etc/httpd/extra/httpd-ssl.conf)

  • To disable IPv6 in bind add -4 to NAMED_OPTIONS in /etc/default/named, add
listen-on-v6 { none; };

to options in /etc/named.conf, and add

plugin query "/usr/lib64/named/filter-aaaa.so" {
  filter-aaaa-on-v4 yes;
  filter-aaaa-on-v6 yes;
};

after options in /etc/named.conf

  • To disable IPv6 in postfix use the option inet_protocols in /etc/postfix/main.cf
  • To disable IPv6 in sendmail use the option Family=inet in DAEMON_OPTIONS and CLIENT_OPTIONS