I am trying to send an IP in IP packet with scapy but I seem to be missing or misunderstanding something. Here is my attempt:
from scapy.all import *
payload = "HelloWorld"
inner = IP(dst="192.168.1.2")
inner.add_payload(payload)
outer = IP(dst="192.168.1.2")
send(outer/inner)
I watched for the packet with wireshark on the destination and it showed that the packet was malformed:
Expert Info (Error/Protocol): IPv6 Hop-by-Hop extension header must appear immediately after IPv6 header
the destination then sends an ICMP packet back with type 3 (destination unreachable) and code 2 (Protocol unreachable).
I have tried setting several protocols on the outer and inner packets (protocol 4 IPv4 encapsulation feels right) but so far they all send back a "protocol unreachable" ICMP packet.
If it makes a difference my intent is to have the inner packet get sent to a different destination than the outer packet. I just thought I should make the simplest possible example to get started. Once I figure out why I am getting a protocol unreachable message I will change the inner packets destination IP.
Suggestions?