# Sending ICMP HOST UNREACHABLE USING SCAPY (PYTHON TOOLS) # Will WORK for UDP/TCP, just give the "packet" (scapy's representation) def send_icmp_unreachable (packet): global MYMAC global IPGATEWAY global INTERFACE p = Ether(src=MYMAC, dst=packet.src)/IP(src=IPGATEWAY, dst=packet.getlayer(IP).src) # ICMP type=3 code=1 Host Unreachable icmp = ICMP() icmp.type = 3 icmp.code = 1 try: sendp(p/icmp/packet.getlayer (IP)/packet.getlayer (UDP), iface=INTERFACE) except: sendp(p/icmp/packet.getlayer (IP)/packet.getlayer (TCP), iface=INTERFACE) return