diff --git a/scapy/all.py b/scapy/all.py
index c76d08b583ccbfbd4147fdf4605a6a3dc0adb61d..fd64c33ba60ff96ce5b394d95755dc6ed92ab78d 100644
--- a/scapy/all.py
+++ b/scapy/all.py
@@ -20,8 +20,9 @@ from asn1packet import *
 
 from utils import *
 from route import *
-from utils6 import *
-from route6 import *
+if conf.ipv6_enabled:
+    from utils6 import *
+    from route6 import *
 from sendrecv import *
 from supersocket import *
 from volatile import *
diff --git a/scapy/config.py b/scapy/config.py
index a6068ef31ecf76ed3ebf3bc152dc04b3c0c95c04..c96ca7af64a13a856a072dabc08461e104f9ba3a 100644
--- a/scapy/config.py
+++ b/scapy/config.py
@@ -3,7 +3,7 @@
 ## Copyright (C) Philippe Biondi <phil@secdev.org>
 ## This program is published under a GPLv2 license
 
-import os,time
+import os,time,socket
 from data import *
 import base_classes
 import themes
@@ -303,6 +303,7 @@ extensions_paths: path or list of paths where extensions are to be looked for
     noenum = Resolve()
     use_pcap = False
     use_dnet = False
+    ipv6_enabled = socket.has_ipv6
     ethertypes = ETHER_TYPES
     protocols = IP_PROTOS
     services_tcp = TCP_SERVICES
@@ -318,6 +319,13 @@ extensions_paths: path or list of paths where extensions are to be looked for
                    "sebek", "skinny", "smb", "snmp", "tftp", "x509", "bluetooth", "dhcp6", "llmnr" ]
     
 
+if not Conf.ipv6_enabled:
+    log_scapy.warning("IPv6 support disabled in Python. Cannot load scapy IPv6 layers.")
+    for m in ["inet6","dhcp6"]:
+        if m in Conf.load_layers:
+            Conf.load_layers.remove(m)
+    
+
 conf=Conf()
 conf.logLevel=30 # 30=Warning
 
diff --git a/scapy/layers/inet.py b/scapy/layers/inet.py
index 935874301f3771c90d2f2941b9b63219e634b12a..94b75d7d5668eeeb4db0d0ee107547d6945d7503 100644
--- a/scapy/layers/inet.py
+++ b/scapy/layers/inet.py
@@ -5,13 +5,12 @@
 
 import os,time,struct,re,socket,new
 from select import select
-
 from scapy.utils import checksum
 from scapy.layers.l2 import *
+from scapy.config import conf
 from scapy.fields import *
 from scapy.packet import *
 from scapy.volatile import *
-from scapy.config import conf
 from scapy.sendrecv import sr,sr1,srp1
 from scapy.plist import PacketList,SndRcvList
 
@@ -278,7 +277,7 @@ class TCP(Packet):
                                      ln)
                 ck=checksum(psdhdr+p)
                 p = p[:16]+struct.pack("!H", ck)+p[18:]
-            elif isinstance(self.underlayer, inet6.IPv6) or isinstance(self.underlayer, inet6._IPv6ExtHdr):
+            elif conf.ipv6_enabled and isinstance(self.underlayer, inet6.IPv6) or isinstance(self.underlayer, inet6._IPv6ExtHdr):
                 ck = inet6.in6_chksum(socket.IPPROTO_TCP, self.underlayer, p)
                 p = p[:16]+struct.pack("!H", ck)+p[18:]
             else:
@@ -302,7 +301,7 @@ class TCP(Packet):
     def mysummary(self):
         if isinstance(self.underlayer, IP):
             return self.underlayer.sprintf("TCP %IP.src%:%TCP.sport% > %IP.dst%:%TCP.dport% %TCP.flags%")
-        elif isinstance(self.underlayer, inet6.IPv6):
+        elif conf.ipv6_enabled and isinstance(self.underlayer, inet6.IPv6):
             return self.underlayer.sprintf("TCP %IPv6.src%:%TCP.sport% > %IPv6.dst%:%TCP.dport% %TCP.flags%")
         else:
             return self.sprintf("TCP %TCP.sport% > %TCP.dport% %TCP.flags%")
@@ -926,8 +925,8 @@ class TracerouteResult(SndRcvList):
         ports = {}
         ports_done = {}
         for s,r in self.res:
-            r = r[IP] or r[inet6.IPv6] or r
-            s = s[IP] or s[inet6.IPv6] or s
+            r = r[IP] or (conf.ipv6_enabled and r[inet6.IPv6]) or r
+            s = s[IP] or (conf.ipv6_enabled and s[inet6.IPv6]) or s
             ips[r.src] = None
             if TCP in s:
                 trace_id = (s.src,s.dst,6,s.dport)
@@ -938,8 +937,8 @@ class TracerouteResult(SndRcvList):
             else:
                 trace_id = (s.src,s.dst,s.proto,0)
             trace = rt.get(trace_id,{})
-            ttl = inet6.IPv6 in s and s.hlim or s.ttl
-            if not (ICMP in r and r[ICMP].type == 11) and not (inet6.IPv6 in r and ICMPv6TimeExceeded in r):
+            ttl = conf.ipv6_enabled and inet6.IPv6 in s and s.hlim or s.ttl
+            if not (ICMP in r and r[ICMP].type == 11) and not (conf.use_inet6 and inet6.IPv6 in r and ICMPv6TimeExceeded in r):
                 if trace_id in ports_done:
                     continue
                 ports_done[trace_id] = None
@@ -1223,4 +1222,5 @@ def fragleak2(target, timeout=0.4, onlyasc=0):
 conf.stats_classic_protocols += [TCP,UDP,ICMP]
 conf.stats_dot11_protocols += [TCP,UDP,ICMP]
 
-from scapy.layers import inet6
+if conf.ipv6_enabled:
+    from scapy.layers import inet6
diff --git a/scapy/layers/inet6.py b/scapy/layers/inet6.py
index 9c15ae11dd219bc2b93c3a6027d574e52d9addf5..c06ee922cbbc9f7fc6e165b001a2976f5f17d18f 100644
--- a/scapy/layers/inet6.py
+++ b/scapy/layers/inet6.py
@@ -20,12 +20,16 @@
 #############################################################################
 
 
+import socket
+if not socket.has_ipv6:
+    raise socket.error("can't use AF_INET6, IPv6 is disabled")
+
+from scapy.config import conf
 from scapy.layers.l2 import *
 from scapy.layers.inet import *
 from scapy.fields import *
 from scapy.packet import *
 from scapy.volatile import *
-from scapy.config import conf
 from scapy.sendrecv import sr,sr1,srp1
 from scapy.as_resolvers import AS_resolver_riswhois
 from scapy.supersocket import SuperSocket,L3RawSocket
diff --git a/scapy/layers/pflog.py b/scapy/layers/pflog.py
index 639d9333108fa73fcc1ce03fdce2a73990af539b..3c62941a7722b0bb93a4d7692d82d6bef517d3d0 100644
--- a/scapy/layers/pflog.py
+++ b/scapy/layers/pflog.py
@@ -6,7 +6,8 @@
 from scapy.packet import *
 from scapy.fields import *
 from scapy.layers.inet import IP
-from scapy.layers.inet6 import IPv6
+if conf.ipv6_enabled:
+    from scapy.layers.inet6 import IPv6
 from scapy.config import conf
 
 class PFLog(Packet):
@@ -48,6 +49,7 @@ class PFLog(Packet):
         return self.sprintf("%PFLog.addrfamily% %PFLog.action% on %PFLog.iface% by rule %PFLog.rulenumber%")
 
 bind_layers(PFLog, IP, addrfamily=socket.AF_INET)
-bind_layers(PFLog, IPv6, addrfamily=socket.AF_INET6)
+if conf.ipv6_enabled:
+    bind_layers(PFLog, IPv6, addrfamily=socket.AF_INET6)
 
 conf.l2types.register(117, PFLog)