0

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?

1 Answers1

1

If you want to send an IP in IP packet (Outer IP header, Inner IP header, IP payload), e.g.:

from scapy.all import *

payload = "TEST"
send(IP(dst="192.168.1.2")/IP(dst="192.168.1.2")/UDP(dport=4444)/payload)
sinkmanu
  • 1,034
  • 1
  • 12
  • 24
  • IP encapsulation IS a thing. See the RFC https://tools.ietf.org/html/rfc2003 (although is that really what the op wants here? who knows...) – Cukic0d Feb 18 '21 at 10:40
  • I think he just wants to send an IP address... But yes, it is difficult to understand what OP wants. :/ – sinkmanu Feb 18 '21 at 10:53
  • @Cukic0d Sorry if I am using incorrect terminology I am very new to this. What is vague about that part of my question? I said I wanted an IP in IP packet which is what this type of encapsulation is called on wikipedia: https://en.wikipedia.org/wiki/IP_in_IP – None O'yur-Buzness Feb 18 '21 at 14:55
  • 1
    I have updated the answer, It is an IP tunnel; like IP in IP. Does it work for you? – sinkmanu Feb 18 '21 at 15:05