summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorsebres <serg.brester@sebres.de>2023-01-09 16:21:36 +0100
committersebres <serg.brester@sebres.de>2023-01-09 16:21:36 +0100
commitd8a9812adc0c5b4accc12cd7d1d16efba02af1aa (patch)
tree76a723a7da9478e4b49009843437c7cbf188b283
parent58834b6734dff4d07e11de304d5aa7be1c14936b (diff)
downloadfail2ban-d8a9812adc0c5b4accc12cd7d1d16efba02af1aa.tar.gz
improve auto detection of IPv6 - try to check sysctl net.ipv6.conf.all.disable_ipv6 (prefer value read from `/proc/sys/net/ipv6/conf/all/disable_ipv6`)
-rw-r--r--fail2ban/server/ipdns.py7
1 files changed, 7 insertions, 0 deletions
diff --git a/fail2ban/server/ipdns.py b/fail2ban/server/ipdns.py
index 68757c25..aca0f6a6 100644
--- a/fail2ban/server/ipdns.py
+++ b/fail2ban/server/ipdns.py
@@ -212,6 +212,13 @@ class DNSUtils:
def _IPv6IsSupportedBySystem():
if not socket.has_ipv6:
return False
+ # try to check sysctl net.ipv6.conf.all.disable_ipv6:
+ try:
+ with open('/proc/sys/net/ipv6/conf/all/disable_ipv6', 'rb') as f:
+ # if 1 - disabled, 0 - enabled
+ return not int(f.read())
+ except:
+ pass
s = None
try:
# try to create INET6 socket: